mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 13:20:30 +00:00
Cleanups, add --frames.
This commit is contained in:
parent
d07712b308
commit
b73f5e77ff
@ -183,6 +183,7 @@ struct global
|
||||
char netplay_server[256];
|
||||
bool netplay_enable;
|
||||
bool netplay_is_client;
|
||||
unsigned netplay_sync_frames;
|
||||
|
||||
#ifdef HAVE_FFMPEG
|
||||
ffemu_t *rec;
|
||||
|
11
netplay.c
11
netplay.c
@ -363,7 +363,6 @@ static void simulate_input(netplay_t *handle)
|
||||
|
||||
handle->buffer[ptr].simulated_input_state = handle->buffer[prev].real_input_state;
|
||||
handle->buffer[ptr].is_simulated = true;
|
||||
//fprintf(stderr, "Predicted output: 0x%hx\n", (unsigned short)handle->buffer[ptr].simulated_input_state);
|
||||
}
|
||||
|
||||
// Poll network to see if we have anything new. If our network buffer is full, we simply have to block for new input data.
|
||||
@ -416,7 +415,6 @@ bool netplay_poll(netplay_t *handle)
|
||||
{
|
||||
handle->buffer[PREV_PTR(handle->self_ptr)].is_simulated = false;
|
||||
handle->buffer[PREV_PTR(handle->self_ptr)].used_real = true;
|
||||
//fprintf(stderr, "Used actual input: 0x%hx\n", (unsigned short)handle->buffer[PREV_PTR(handle->self_ptr)].real_input_state);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -494,24 +492,15 @@ void netplay_post_frame(netplay_t *handle)
|
||||
handle->is_replay = true;
|
||||
handle->tmp_ptr = handle->other_ptr;
|
||||
psnes_unserialize(handle->buffer[handle->other_ptr].state, handle->state_size);
|
||||
int cnt = 0;
|
||||
while (handle->tmp_ptr != handle->self_ptr)
|
||||
{
|
||||
cnt++;
|
||||
//fprintf(stderr, "Replaying frame @ ptr: %lu\n", handle->tmp_ptr);
|
||||
psnes_serialize(handle->buffer[handle->tmp_ptr].state, handle->state_size);
|
||||
psnes_run();
|
||||
handle->tmp_ptr = NEXT_PTR(handle->tmp_ptr);
|
||||
}
|
||||
//fprintf(stderr, "Read ptr: %lu, Other ptr: %lu, Self ptr: %lu\n", handle->read_ptr, handle->other_ptr, handle->self_ptr);
|
||||
//fprintf(stderr, "Replayed %d frames!\n", cnt);
|
||||
handle->other_ptr = handle->read_ptr;
|
||||
handle->is_replay = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//fprintf(stderr, "Perfect prediction: Ratio: %.3f%%\n", (float)perfect_cnt * 100.0f / cnt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
12
ssnes.c
12
ssnes.c
@ -345,6 +345,7 @@ static void print_help(void)
|
||||
puts("\t-P/--bsvplay: Playback a BSV movie file.");
|
||||
puts("\t-H/--host: Host netplay as player 1.");
|
||||
puts("\t-C/--connect: Connect to netplay as player 2.");
|
||||
puts("\t-F/--frames: Sync frames when using netplay.");
|
||||
|
||||
#ifdef HAVE_FFMPEG
|
||||
puts("\t-r/--record: Path to record video file. Settings for video/audio codecs are found in config file.");
|
||||
@ -396,6 +397,7 @@ static void parse_input(int argc, char *argv[])
|
||||
{ "bsvplay", 1, NULL, 'P' },
|
||||
{ "host", 0, NULL, 'H' },
|
||||
{ "connect", 1, NULL, 'C' },
|
||||
{ "frames", 1, NULL, 'F' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
@ -413,7 +415,7 @@ static void parse_input(int argc, char *argv[])
|
||||
#define CONFIG_FILE_ARG
|
||||
#endif
|
||||
|
||||
char optstring[] = "hs:vS:m:p4jJg:b:B:Y:Z:P:HC:" FFMPEG_RECORD_ARG CONFIG_FILE_ARG;
|
||||
char optstring[] = "hs:vS:m:p4jJg:b:B:Y:Z:P:HC:F:" FFMPEG_RECORD_ARG CONFIG_FILE_ARG;
|
||||
for(;;)
|
||||
{
|
||||
int c = getopt_long(argc, argv, optstring, opts, &option_index);
|
||||
@ -521,6 +523,12 @@ static void parse_input(int argc, char *argv[])
|
||||
strncpy(g_extern.netplay_server, optarg, sizeof(g_extern.netplay_server) - 1);
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
g_extern.netplay_sync_frames = strtol(optarg, NULL, 0);
|
||||
if (g_extern.netplay_sync_frames < 32)
|
||||
g_extern.netplay_sync_frames = 32;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
print_help();
|
||||
exit(1);
|
||||
@ -774,7 +782,7 @@ static void init_netplay(void)
|
||||
else
|
||||
SSNES_LOG("Waiting for client...\n");
|
||||
|
||||
g_extern.netplay = netplay_new(g_extern.netplay_is_client ? g_extern.netplay_server : NULL, 55435, 4, &cbs);
|
||||
g_extern.netplay = netplay_new(g_extern.netplay_is_client ? g_extern.netplay_server : NULL, 55435, g_extern.netplay_sync_frames, &cbs);
|
||||
if (!g_extern.netplay)
|
||||
{
|
||||
g_extern.netplay_is_client = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user