audio fix, turn off lowpass, add timings (not working)

This commit is contained in:
dborth 2008-10-21 07:50:37 +00:00
parent a4bbd222cc
commit c900a87eaa
11 changed files with 144 additions and 51 deletions

View File

@ -16,7 +16,6 @@
extern int NoWaiting;
extern FCEUGI *GI;
void DSMFix(unsigned int msg);
void StopSound(void);
extern int eoptions;

View File

@ -23,7 +23,7 @@ void
DefaultSettings ()
{
GCSettings.currpal = 0;
GCSettings.timing = 0;
GCSettings.timing = 0; // 0 - NTSC, 1 - PAL
GCSettings.FSDisable = 1;
GCSettings.zapper = 0;
GCSettings.crosshair = 1;

View File

@ -15,8 +15,8 @@
void DefaultSettings ();
#define VERSIONNUM "2.0.5"
#define VERSIONSTR "FCE Ultra GX 2.0.5"
#define VERSIONNUM "2.0.6"
#define VERSIONSTR "FCE Ultra GX 2.0.6"
#define NOTSILENT 0
#define SILENT 1
@ -59,5 +59,6 @@ struct SGCSettings{
};
extern struct SGCSettings GCSettings;
extern int ConfigRequested;
#endif

View File

@ -20,32 +20,84 @@
#include "types.h"
#include "gcvideo.h"
#include "pad.h"
#include "fceuconfig.h"
#include "fceuload.h"
#include "fceustate.h"
#include "fceuram.h"
#include "common.h"
#include "menudraw.h"
#include "menu.h"
#include "fceuconfig.h"
#include "preferences.h"
#include "gcaudio.h"
#include "gcvideo.h"
#include "pad.h"
#ifdef WII_DVD
#include <di/di.h>
#endif
unsigned char * nesrom = NULL;
extern bool romLoaded;
int ConfigRequested = 0;
bool isWii;
uint8 *xbsave=NULL;
long long prev;
long long now;
long long gettime();
u32 diff_usec(long long start,long long end);
extern bool romLoaded;
extern int cleanSFMDATA();
extern void ResetNES(void);
extern uint8 FDSBIOS[8192];
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count);
/****************************************************************************
* setFrameTimer()
* change frame timings depending on whether ROM is NTSC or PAL
***************************************************************************/
int normaldiff;
void setFrameTimer()
{
if (GCSettings.timing) // PAL
{
if(vmode_60hz == 1)
normaldiff = 20000; // 50hz
else
normaldiff = 16667; // 60hz
}
else
{
if(vmode_60hz == 1)
normaldiff = 16667; // 60hz
else
normaldiff = 20000; // 50hz
}
FrameTimer = 0;
prev = gettime();
}
void SyncSpeed()
{
now = gettime();
int diff = normaldiff - diff_usec(prev, now);
if (diff > 0) // ahead - take a nap
usleep(diff);
prev = now;
FrameTimer--;
}
/****************************************************************************
* main
* This is where it all happens!
***************************************************************************/
int main(int argc, char *argv[])
{
@ -62,6 +114,8 @@ int main(int argc, char *argv[])
WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
#endif
PAD_Init();
initDisplay();
/*** Initialise freetype ***/
@ -86,8 +140,7 @@ int main(int argc, char *argv[])
return 1;
}
FCEUI_SetVidSystem(0); // 0 - NTSC, 1 - PAL
FCEUI_SetGameGenie(0); // 0 - OFF, 1 - ON
FCEUI_SetGameGenie(0); // 0 - OFF, 1 - ON
memset(FDSBIOS, 0, sizeof(FDSBIOS)); // clear FDS BIOS memory
cleanSFMDATA(); // clear state data
@ -103,31 +156,57 @@ int main(int argc, char *argv[])
selectedMenu = 3; // change to preferences menu
}
// Go to main menu
MainMenu (selectedMenu);
while (1)
while (1) // main loop
{
uint8 *gfx;
int32 *sound;
int32 ssize;
MainMenu(selectedMenu);
selectedMenu = 4; // return to game menu from now on
FCEUI_Emulate(&gfx, &sound, &ssize, 0);
xbsave = gfx;
FCEUD_Update(gfx, sound, ssize);
setFrameTimer(); // set frametimer method before emulation
FCEUI_SetVidSystem(GCSettings.timing);
while(1) // emulation loop
{
uint8 *gfx;
int32 *sound;
int32 ssize;
FCEUI_Emulate(&gfx, &sound, &ssize, 0);
xbsave = gfx;
FCEUD_Update(gfx, sound, ssize);
if(ConfigRequested)
{
if (GCSettings.AutoSave == 1)
{
SaveRAM(GCSettings.SaveMethod, SILENT);
}
else if (GCSettings.AutoSave == 2)
{
SaveState(GCSettings.SaveMethod, SILENT);
}
else if(GCSettings.AutoSave == 3)
{
SaveRAM(GCSettings.SaveMethod, SILENT);
SaveState(GCSettings.SaveMethod, SILENT);
}
ConfigRequested = 0;
break; // leave emulation loop
}
SyncSpeed();
}
}
return 0;
}
/****************************************************************************
* FCEU Support Functions to be written
* FCEU Support Functions
****************************************************************************/
// File Control
FILE *FCEUD_UTF8fopen(const char *n, const char *m)
{
return NULL;
//return(fopen(n,m));
}
// General Logging

View File

@ -95,7 +95,7 @@ int GCMemROM(int method, int size)
FCEUI_Sound(SAMPLERATE);
FCEUI_SetSoundVolume(100); // 0-100
FCEUI_SetSoundQuality(1); // 0 - low, 1 - high
FCEUI_SetLowPass(1);
FCEUI_SetLowPass(0);
InitialisePads();

View File

@ -93,7 +93,7 @@ void StopAudio()
void PlaySound( int *Buffer, int count )
{
int i;
s16 sample;
u16 sample;
u32 *dst = (u32 *)mixbuffer;
for( i = 0; i < count; i++ )

View File

@ -34,6 +34,8 @@ int FDSSwitchRequested;
unsigned int *xfb[2]; /*** Framebuffer - used throughout ***/
GXRModeObj *vmode;
int screenheight;
int vmode_60hz = 0;
bool progressive = false;
/*** Need something to hold the PC palette ***/
struct pcpal {
@ -52,6 +54,7 @@ static Mtx projectionMatrix,modelViewMatrix;
void CheesyScale(unsigned char *XBuf);
int whichfb = 0;
int copynow = GX_FALSE;
u32 FrameTimer = 0;
/****************************************************************************
* VideoThreading
@ -104,11 +107,12 @@ static void copy_to_xfb()
{
if (copynow == GX_TRUE)
{
GX_CopyDisp(xfb[whichfb],GX_TRUE);
GX_Flush();
copynow = GX_FALSE;
GX_CopyDisp(xfb[whichfb],GX_TRUE);
GX_Flush();
copynow = GX_FALSE;
}
SMBTimer++;
FrameTimer++;
// FDS switch disk requested - need to eject, select, and insert
// but not all at once!
@ -292,6 +296,30 @@ void initDisplay()
vmode = VIDEO_GetPreferredMode(NULL);
switch (vmode->viTVMode >> 2)
{
case VI_PAL:
// 576 lines (PAL 50Hz)
// display should be centered vertically (borders)
vmode = &TVPal574IntDfScale;
vmode->xfbHeight = 480;
vmode->viYOrigin = (VI_MAX_HEIGHT_PAL - 480)/2;
vmode->viHeight = 480;
vmode_60hz = 0;
break;
case VI_NTSC:
// 480 lines (NTSC 60hz)
vmode_60hz = 1;
break;
default:
// 480 lines (PAL 60Hz)
vmode_60hz = 1;
break;
}
#ifdef HW_DOL
/* we have component cables, but the preferred mode is interlaced
* why don't we switch into progressive?
@ -300,6 +328,10 @@ void initDisplay()
vmode = &TVNtsc480Prog;
#endif
// check for progressive scan
if (vmode->viTVMode == VI_TVMODE_NTSC_PROG)
progressive = true;
VIDEO_Configure(vmode);
screenheight = vmode->xfbHeight;
@ -307,7 +339,6 @@ void initDisplay()
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
VIDEO_SetNextFramebuffer(xfb[0]);
VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK);
VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK);
VIDEO_SetNextFramebuffer (xfb[0]);
@ -322,7 +353,6 @@ void initDisplay()
VIDEO_SetPostRetraceCallback((VIRetraceCallback)UpdatePadsCB);
VIDEO_SetPreRetraceCallback((VIRetraceCallback)copy_to_xfb);
PAD_Init();
StartGX();
InitVideoThread ();
@ -378,7 +408,6 @@ void RenderFrame(char *XBuf, int style)
VIDEO_SetNextFramebuffer(xfb[whichfb]);
VIDEO_Flush();
copynow = GX_TRUE;
// Return to caller, don't waste time waiting for vb
LWP_ResumeThread (vbthread);

View File

@ -27,5 +27,8 @@ struct st_palettes {
extern struct st_palettes palettes[];
extern int FDSSwitchRequested;
extern int vmode_60hz;
extern bool progressive;
extern u32 FrameTimer;
#endif

View File

@ -166,7 +166,6 @@ EmulatorMenu ()
case 3: // timing
GCSettings.timing ^= 1;
FCEUI_SetVidSystem(GCSettings.timing);
break;
case 4:

View File

@ -20,8 +20,6 @@
#include "pad.h"
#include "gcaudio.h"
#include "menu.h"
#include "fceustate.h"
#include "fceuram.h"
#include "gcvideo.h"
#include "filesel.h"
@ -469,22 +467,7 @@ void GetJoy()
)
{
StopAudio();
if (GCSettings.AutoSave == 1)
{
SaveRAM(GCSettings.SaveMethod, SILENT);
}
else if (GCSettings.AutoSave == 2)
{
SaveState(GCSettings.SaveMethod, SILENT);
}
else if(GCSettings.AutoSave == 3)
{
SaveRAM(GCSettings.SaveMethod, SILENT);
SaveState(GCSettings.SaveMethod, SILENT);
}
MainMenu(4);
ConfigRequested = 1;
}
else
{

View File

@ -256,7 +256,7 @@ decodePrefsData (int method)
if(verMajor == '2' && verPoint < '3') // less than version 2.0.3
return false; // reset settings
else if(verMajor > '2' || verMinor > '0' || verPoint > '5') // some future version
else if(verMajor > '2' || verMinor > '0' || verPoint > '6') // some future version
return false; // reset settings
// File Settings