Skip to content

Commit

Permalink
Simplify some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Jan 24, 2024
1 parent 01d0351 commit d49b95d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 53 deletions.
11 changes: 5 additions & 6 deletions libretro/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -2868,20 +2868,19 @@ static void retro_run_blit(uint8_t *gfx)

void retro_run(void)
{
uint8_t *gfx;
int32_t ssize = 0;
bool updated = false;

if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
check_variables(false);

FCEUD_UpdateInput();
FCEUI_Emulate(&gfx, &sound, &ssize, 0);
ssize = FCEUI_Emulate();

retro_run_blit(gfx);
retro_run_blit(XBuf);

stereo_filter_apply(sound, ssize);
audio_batch_cb((const int16_t*)sound, ssize);
stereo_filter_apply(WaveFinal, ssize);
audio_batch_cb((const int16_t*)WaveFinal, ssize);
}

size_t retro_serialize_size(void)
Expand Down Expand Up @@ -2970,7 +2969,7 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code)
int c;
int type = 1;

if (code == NULL)
if (!code)
return;

sprintf(name, "N/A");
Expand Down
8 changes: 1 addition & 7 deletions src/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ FCEUGI *FCEUI_LoadGame(const char *name, const uint8_t *databuf, size_t databufs
int FCEUI_Initialize(void);

/* Emulates a frame. */
void FCEUI_Emulate(uint8 **, int32 **, int32 *, int);
int FCEUI_Emulate(void);

/* Closes currently loaded game */
void FCEUI_CloseGame(void);
Expand All @@ -110,12 +110,6 @@ void FCEUI_SetGameGenie(int a);
/* Set video system a=0 NTSC, a=1 PAL */
void FCEUI_SetVidSystem(int a);

/* Convenience function; returns currently emulated video system(0=NTSC, 1=PAL). */
int FCEUI_GetCurrentVidSystem(int *slstart, int *slend);

/* First and last scanlines to render, for ntsc and pal emulation. */
void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall);

/* Sets the base directory (bios and palette files are saved
in this directory. */
void FCEUI_SetBaseDirectory(const char *dir);
Expand Down
45 changes: 7 additions & 38 deletions src/fceu.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void FCEUI_CloseGame(void)
GameInfo = 0;
}

void ResetGameLoaded(void)
static void ResetGameLoaded(void)
{
if (GameInfo)
FCEUI_CloseGame();
Expand Down Expand Up @@ -301,23 +301,19 @@ void FCEUI_Kill(void) {
FCEU_KillGenie();
}

void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int skip) {
int FCEUI_Emulate(void) {
int r, ssize;

FCEU_UpdateInput();
if (geniestage != 1) FCEU_ApplyPeriodicCheats();
r = FCEUPPU_Loop(skip);

ssize = FlushEmulateSound();
r = FCEUPPU_Loop(0);
ssize = FlushEmulateSound();

timestampbase += timestamp;
timestampbase += timestamp;

timestamp = 0;
timestamp = 0;
sound_timestamp = 0;

*pXBuf = skip ? 0 : XBuf;
*SoundBuf = WaveFinal;
*SoundBufSize = ssize;
return ssize;
}


Expand Down Expand Up @@ -442,24 +438,6 @@ void FCEU_PrintError(char *format, ...)
va_end(ap);
}

void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall)
{
FSettings.UsrFirstSLine[0] = ntscf;
FSettings.UsrLastSLine[0] = ntscl;
FSettings.UsrFirstSLine[1] = palf;
FSettings.UsrLastSLine[1] = pall;
if (PAL || dendy)
{
FSettings.FirstSLine = FSettings.UsrFirstSLine[1];
FSettings.LastSLine = FSettings.UsrLastSLine[1];
}
else
{
FSettings.FirstSLine = FSettings.UsrFirstSLine[0];
FSettings.LastSLine = FSettings.UsrLastSLine[0];
}
}

void FCEUI_SetVidSystem(int a)
{
FSettings.PAL = a ? 1 : 0;
Expand All @@ -471,15 +449,6 @@ void FCEUI_SetVidSystem(int a)
FCEU_ResetPalette();
}

int FCEUI_GetCurrentVidSystem(int *slstart, int *slend)
{
if (slstart)
*slstart = FSettings.FirstSLine;
if (slend)
*slend = FSettings.LastSLine;
return(PAL);
}

void FCEUI_SetGameGenie(int a)
{
FSettings.GameGenie = a ? 1 : 0;
Expand Down
2 changes: 0 additions & 2 deletions src/fceu.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ extern unsigned swapDuty; /* Swap bits 6 & 7 of $4000/$4004 to mimic bug
* found on some famiclones/Dendy models.
*/

void ResetGameLoaded(void);

void FCEU_MemoryRand(uint8 *ptr, uint32 size);
void SetReadHandler(int32 start, int32 end, readfunc func);
void SetWriteHandler(int32 start, int32 end, writefunc func);
Expand Down

0 comments on commit d49b95d

Please sign in to comment.