2018-12-03 12:26:02 +01:00
|
|
|
/*****************************************************************************\
|
|
|
|
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
|
|
|
This file is licensed under the Snes9x License.
|
|
|
|
For further information, consult the LICENSE file in the root directory.
|
|
|
|
\*****************************************************************************/
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2018-11-14 03:24:16 +01:00
|
|
|
#ifdef GEKKO
|
|
|
|
void S9xResetLogger (void) { }
|
|
|
|
void S9xCloseLogger (void) { }
|
|
|
|
void S9xVideoLogger (void *pixels, int width, int height, int depth, int bytes_per_line) { }
|
|
|
|
void S9xAudioLogger (void *samples, int length) { }
|
|
|
|
#else
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
#include "snes9x.h"
|
|
|
|
#include "movie.h"
|
|
|
|
#include "logger.h"
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
static int resetno = 0;
|
|
|
|
static int framecounter = 0;
|
|
|
|
static FILE *video = NULL;
|
|
|
|
static FILE *audio = NULL;
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2009-11-25 07:35:14 +01:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
void S9xResetLogger (void)
|
2009-11-25 07:35:14 +01:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
if (!Settings.DumpStreams)
|
|
|
|
return;
|
|
|
|
|
|
|
|
char buffer[128];
|
|
|
|
|
|
|
|
S9xCloseLogger();
|
|
|
|
framecounter = 0;
|
|
|
|
|
|
|
|
sprintf(buffer, "videostream%d.dat", resetno);
|
|
|
|
video = fopen(buffer, "wb");
|
|
|
|
if (!video)
|
|
|
|
{
|
|
|
|
printf("Opening %s failed. Logging cancelled.\n", buffer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(buffer, "audiostream%d.dat", resetno);
|
|
|
|
audio = fopen(buffer, "wb");
|
|
|
|
if (!audio)
|
|
|
|
{
|
|
|
|
printf("Opening %s failed. Logging cancelled.\n", buffer);
|
|
|
|
fclose(video);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
resetno++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void S9xCloseLogger (void)
|
2009-11-25 07:35:14 +01:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
if (video)
|
|
|
|
{
|
|
|
|
fclose(video);
|
|
|
|
video = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (audio)
|
|
|
|
{
|
|
|
|
fclose(audio);
|
|
|
|
audio = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void S9xVideoLogger (void *pixels, int width, int height, int depth, int bytes_per_line)
|
|
|
|
{
|
|
|
|
int fc = S9xMovieGetFrameCounter();
|
|
|
|
if (fc > 0)
|
|
|
|
framecounter = fc;
|
|
|
|
else
|
|
|
|
framecounter++;
|
|
|
|
|
|
|
|
if (video)
|
|
|
|
{
|
|
|
|
char *data = (char *) pixels;
|
|
|
|
|
|
|
|
for (int i = 0; i < height; i++)
|
2018-11-20 12:13:06 +01:00
|
|
|
{
|
|
|
|
if (!fwrite(data + i * bytes_per_line, depth, width, video))
|
|
|
|
printf ("Error writing video data.\n");
|
|
|
|
}
|
2010-01-27 23:08:56 +01:00
|
|
|
fflush(video);
|
|
|
|
fflush(audio);
|
|
|
|
|
|
|
|
if (Settings.DumpStreamsMaxFrames > 0 && framecounter >= Settings.DumpStreamsMaxFrames)
|
|
|
|
{
|
|
|
|
printf("Logging ended.\n");
|
|
|
|
S9xCloseLogger();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void S9xAudioLogger (void *samples, int length)
|
|
|
|
{
|
|
|
|
if (audio)
|
|
|
|
{
|
2018-11-20 12:13:06 +01:00
|
|
|
if (!fwrite(samples, 1, length, audio))
|
|
|
|
printf ("Error writing audio data.\n");
|
2010-01-27 23:08:56 +01:00
|
|
|
}
|
|
|
|
}
|
2018-11-14 03:24:16 +01:00
|
|
|
|
|
|
|
#endif
|