From 7b75fb14486fed1e277971b9da365857192ea070 Mon Sep 17 00:00:00 2001 From: rheiny Date: Sun, 11 Feb 2007 12:04:24 +0000 Subject: [PATCH] Trying to untangle the horrible web of file dependencies --- src/drivers/win/main.cpp | 67 ++-------------------------- src/drivers/win/main.h | 89 ++++++++++++++++++++++++++++---------- src/drivers/win/sound.cpp | 8 ++-- src/drivers/win/sound.h | 9 ++++ src/drivers/win/wave.cpp | 8 +++- src/drivers/win/window.cpp | 5 ++- src/wave.cpp | 2 +- src/wave.h | 3 ++ vc8/fceux.vcproj | 52 ++++++++++++++++++++++ 9 files changed, 151 insertions(+), 92 deletions(-) create mode 100644 src/drivers/win/sound.h diff --git a/src/drivers/win/main.cpp b/src/drivers/win/main.cpp index cc23cf4f..ccb31af1 100644 --- a/src/drivers/win/main.cpp +++ b/src/drivers/win/main.cpp @@ -50,26 +50,11 @@ #include "tracer.h" #include "cdlogger.h" +#include "main.h" #include "basicbot.h" #include "args.h" #include "config.h" -// #defines - -#define VNSCLIP ((eoptions&EO_CLIPSIDES)?8:0) -#define VNSWID ((eoptions&EO_CLIPSIDES)?240:256) - -#define SO_FORCE8BIT 1 -#define SO_SECONDARY 2 -#define SO_GFOCUS 4 -#define SO_D16VOL 8 -#define SO_MUTEFA 16 -#define SO_OLDUP 32 - -#define GOO_DISABLESS 1 /* Disable screen saver when game is loaded. */ -#define GOO_CONFIRMEXIT 2 /* Confirmation before exiting. */ -#define GOO_POWERRESET 4 /* Confirm on power/reset. */ - //--------------------------- //mbg merge 6/29/06 - new aboutbox @@ -106,6 +91,8 @@ void ApplyDefaultCommandMapping(void); uint8 *xbsave = NULL; int eoptions = EO_BGRUN | EO_FORCEISCALE; +int soundoptions = SO_SECONDARY | SO_GFOCUS; + /** * Handle of the main window. **/ @@ -118,20 +105,6 @@ HINSTANCE fceu_hInstance; HRESULT ddrval; -/** -* Contains the names of the overridden standard directories -* in the order cheats, misc, nonvol, states, snaps, ..., base -**/ -static char *directory_names[6] = {0, 0, 0, 0, 0, 0}; - -/** -* Contains the names of the default directories. -**/ -static const char *default_directory_names[5] = {"cheats", "sav", "fcs", "snaps", "movie"}; - -#define NUMBER_OF_DIRECTORIES sizeof(directory_names) / sizeof(*directory_names) -#define NUMBER_OF_DEFAULT_DIRECTORIES sizeof(default_directory_names) / sizeof(*default_directory_names) - static char TempArray[2048]; /** @@ -142,49 +115,18 @@ static char BaseDirectory[2048]; static int exiting = 0; static volatile int moocow = 0; -/* Some timing-related variables (now ignored). */ -static int maxconbskip = 32; /* Maximum consecutive blit skips. */ -static int ffbskip = 32; /* Blit skips per blit when FF-ing */ - -static int moviereadonly = 1; - -static int fullscreen = 0; -static int soundflush = 0; -// Flag that indicates whether Game Genie is enabled or not. -static int genie = 0; - -// Flag that indicates whether PAL Emulation is enabled or not. -static int pal_emulation = 0; -static int status_icon = 1; static int windowedfailed; -static double saspectw = 1, saspecth = 1; -static double winsizemulx = 1, winsizemuly = 1; -static int winwidth, winheight; -static int ismaximized = 0; static volatile int nofocus = 0; static volatile int _userpause = 0; //mbg merge 7/18/06 changed tasbuild was using this only in a couple of places -static uint32 goptions = GOO_DISABLESS; - -static int soundrate = 44100; -static int soundbuftime = 50; -/*static*/ int soundoptions = SO_SECONDARY | SO_GFOCUS; -static int soundvolume = 100; -static int soundquality = 0; extern int autoHoldKey, autoHoldClearKey; extern int frame_display, input_display; //mbg merge 7/17/06 did these have to be unsigned? static int srendline, erendline; -static int srendlinen = 8; -static int erendlinen = 231; -static int srendlinep = 0; -static int erendlinep = 239; static int totallines; -static uint8 cpalette[192]; -static int vmod = 0; int soundo = 1; static int ntsccol = 0, ntsctint, ntschue; @@ -291,7 +233,6 @@ void CreateDirs(void) DefaultDirectoryWalker(DirectoryCreator); } -static char *gfsdir=0; /** * Fills the BaseDirectory string @@ -440,7 +381,7 @@ void DoPriority(void) // TODO: HORRIBLE -#include "sound.cpp" +//#include "sound.cpp" #include "video.cpp" #include "window.cpp" diff --git a/src/drivers/win/main.h b/src/drivers/win/main.h index d3a52643..6d894ed0 100644 --- a/src/drivers/win/main.h +++ b/src/drivers/win/main.h @@ -1,29 +1,74 @@ +#ifndef WIN_MAIN_H +#define WIN_MAIN_H + #include "../../types.h" -static int genie; -static int pal_emulation; -static int status_icon; -static int fullscreen; -static int vmod; -static char *gfsdir; -static char *directory_names[6]; -static double winsizemulx, winsizemuly; -static double saspectw, saspecth; -static int soundrate; -static int soundbuftime; -static int soundvolume; -static int soundquality; -static uint32 goptions; +// #defines + +#define VNSCLIP ((eoptions&EO_CLIPSIDES)?8:0) +#define VNSWID ((eoptions&EO_CLIPSIDES)?240:256) + +#define SO_FORCE8BIT 1 +#define SO_SECONDARY 2 +#define SO_GFOCUS 4 +#define SO_D16VOL 8 +#define SO_MUTEFA 16 +#define SO_OLDUP 32 + +#define GOO_DISABLESS 1 /* Disable screen saver when game is loaded. */ +#define GOO_CONFIRMEXIT 2 /* Confirmation before exiting. */ +#define GOO_POWERRESET 4 /* Confirm on power/reset. */ + +/* Some timing-related variables (now ignored). */ +static int maxconbskip = 32; /* Maximum consecutive blit skips. */ +static int ffbskip = 32; /* Blit skips per blit when FF-ing */ + +static int moviereadonly = 1; + +static int fullscreen = 0; +static int soundflush = 0; +// Flag that indicates whether Game Genie is enabled or not. +static int genie = 0; + +// Flag that indicates whether PAL Emulation is enabled or not. +static int pal_emulation = 0; +static int status_icon = 1; + +static int vmod = 0; +static char *gfsdir=0; + +/** +* Contains the names of the overridden standard directories +* in the order cheats, misc, nonvol, states, snaps, ..., base +**/ +static char *directory_names[6] = {0, 0, 0, 0, 0, 0}; + +/** +* Contains the names of the default directories. +**/ +static const char *default_directory_names[5] = {"cheats", "sav", "fcs", "snaps", "movie"}; + +#define NUMBER_OF_DIRECTORIES sizeof(directory_names) / sizeof(*directory_names) +#define NUMBER_OF_DEFAULT_DIRECTORIES sizeof(default_directory_names) / sizeof(*default_directory_names) + +static double saspectw = 1, saspecth = 1; +static double winsizemulx = 1, winsizemuly = 1; +static int winwidth, winheight; +static int ismaximized = 0; +static uint32 goptions = GOO_DISABLESS; + +static int soundrate = 44100; +static int soundbuftime = 50; +static int soundvolume = 100; +static int soundquality = 0; static uint8 cpalette[192]; -static int srendlinen; -static int erendlinen; -static int srendlinep; -static int erendlinep; -static int ismaximized; -static int maxconbskip; -static int ffbskip; -static int moviereadonly; +static int srendlinen = 8; +static int erendlinen = 231; +static int srendlinep = 0; +static int erendlinep = 239; extern int soundo; extern int eoptions; extern int soundoptions; + +#endif \ No newline at end of file diff --git a/src/drivers/win/sound.cpp b/src/drivers/win/sound.cpp index 1c3d62f6..2780feff 100644 --- a/src/drivers/win/sound.cpp +++ b/src/drivers/win/sound.cpp @@ -19,6 +19,8 @@ */ #include +#include "common.h" +#include "main.h" /// controls whether playback is muted static bool mute = false; @@ -502,7 +504,7 @@ BOOL CALLBACK SoundConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara /** * Shows the sounds configuration dialog. **/ -void ConfigSound(void) +void ConfigSound() { if(!uug) { @@ -551,7 +553,7 @@ static int32 fps_scale_table[]= { 3, 3, 4, 8, 16, 32, 64, 128, 192, 256, 384, 512, 768, 1024, 2048, 4096, 8192, 16384, 16384}; int32 fps_scale = 256; -static void RefreshThrottleFPS(void) +void RefreshThrottleFPS() { printf("WTF\n"); fflush(stdout); @@ -597,4 +599,4 @@ void FCEUD_SetEmulationSpeed(int cmd) } -#include "wave.cpp" +//#include "wave.cpp" diff --git a/src/drivers/win/sound.h b/src/drivers/win/sound.h new file mode 100644 index 00000000..a8264008 --- /dev/null +++ b/src/drivers/win/sound.h @@ -0,0 +1,9 @@ +extern int32 fps_scale; + +void RefreshThrottleFPS(); +void ConfigSound(); +int InitSound(); +void TrashSound(); +void win_SoundSetScale(int scale); +void win_SoundWriteData(int32 *buffer, int count); +void win_Throttle(); \ No newline at end of file diff --git a/src/drivers/win/wave.cpp b/src/drivers/win/wave.cpp index 411170f1..90a28e83 100644 --- a/src/drivers/win/wave.cpp +++ b/src/drivers/win/wave.cpp @@ -18,7 +18,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -int CloseWave(void) + +#include "common.h" +#include "../../wave.h" + +int CloseWave() { return(FCEUI_EndWaveRecord()); @@ -29,7 +33,7 @@ int CloseWave(void) * * @return Flag that indicates failure (0) or success (1). **/ -int CreateSoundSave(void) +int CreateSoundSave() { const char filter[]="MS WAVE(*.wav)\0*.wav\0"; char nameo[2048]; diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index de7d40b3..b24442e5 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -20,6 +20,9 @@ #include "state.cpp" /* Save/Load state AS */ +#include "sound.h" +#include "wave.h" + // #defines #define MAX(x,y) ((x)<(y)?(y):(x)) @@ -382,7 +385,7 @@ void UpdateRecentArray(const char* addString, char** bufferArray, unsigned int a } // Move the other items down. - for(x = arrayLen - 1; x; x--) + for(unsigned int x = arrayLen - 1; x; x--) { bufferArray[x] = bufferArray[x - 1]; } diff --git a/src/wave.cpp b/src/wave.cpp index 6a47c5a3..9dbe1b64 100644 --- a/src/wave.cpp +++ b/src/wave.cpp @@ -53,7 +53,7 @@ void FCEU_WriteWaveData(int32 *Buffer, int Count) #endif } -int FCEUI_EndWaveRecord(void) +int FCEUI_EndWaveRecord() { long s; diff --git a/src/wave.h b/src/wave.h index c2947a73..81065c5e 100644 --- a/src/wave.h +++ b/src/wave.h @@ -1 +1,4 @@ +#include "types.h" + void FCEU_WriteWaveData(int32 *Buffer, int Count); +int FCEUI_EndWaveRecord(); \ No newline at end of file diff --git a/vc8/fceux.vcproj b/vc8/fceux.vcproj index eeb7e93e..1f985978 100644 --- a/vc8/fceux.vcproj +++ b/vc8/fceux.vcproj @@ -1010,6 +1010,32 @@ RelativePath="..\src\drivers\win\resource.h" > + + + + + + + + + + @@ -1022,6 +1048,32 @@ RelativePath="..\src\drivers\win\video.h" > + + + + + + + + + +