mirror of
https://github.com/libretro/beetle-lynx-libretro.git
synced 2024-11-27 02:12:46 +00:00
Make threading code self-contained
This commit is contained in:
parent
826403c127
commit
e1b305a8b4
2
Makefile
2
Makefile
@ -135,7 +135,7 @@ else
|
||||
endif
|
||||
|
||||
ifeq ($(NEED_THREADING), 1)
|
||||
THREAD_STUBS := thread.cpp
|
||||
THREAD_STUBS := thread.cpp stubs_thread.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(NEED_CD), 1)
|
||||
|
39
libretro.cpp
39
libretro.cpp
@ -24,14 +24,20 @@ std::string retro_base_directory;
|
||||
std::string retro_base_name;
|
||||
|
||||
#if defined(WANT_PSX_EMU)
|
||||
const char *mednafen_core_str = "Mednafen PSX";
|
||||
#define MEDNAFEN_CORE_NAME "Mednafen PSX"
|
||||
#define MEDNAFEN_CORE_EXTENSIONS "cue|CUE|toc|TOC"
|
||||
#define MEDNAFEN_CORE_TIMING_FPS 59.85398
|
||||
#define MEDNAFEN_CORE_GEOMETRY_BASE_W 320
|
||||
#define MEDNAFEN_CORE_GEOMETRY_BASE_H 240
|
||||
#define MEDNAFEN_CORE_GEOMETRY_MAX_W 640
|
||||
#define MEDNAFEN_CORE_GEOMETRY_MAX_H 480
|
||||
#define MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO (4.0 / 3.0)
|
||||
#define FB_WIDTH 680
|
||||
#define FB_HEIGHT 576
|
||||
#elif defined(WANT_PCE_FAST_EMU)
|
||||
#define MEDNAFEN_CORE_NAME "Mednafen PCE Fast"
|
||||
const char *mednafen_core_str = "Mednafen PCE Fast";
|
||||
#endif
|
||||
const char *mednafen_core_str = MEDNAFEN_CORE_NAME;
|
||||
|
||||
static void check_system_specs(void)
|
||||
{
|
||||
@ -283,22 +289,26 @@ void retro_run()
|
||||
unsigned width = rects[0].w;
|
||||
unsigned height = spec.DisplayRect.h;
|
||||
unsigned int ptrDiff = 0;
|
||||
|
||||
#ifdef WANT_PSX_EMU
|
||||
// This is for PAL, the core implements PAL over NTSC TV so you get the
|
||||
// infamous PAL borders. This removes them. The PS1 supports only two horizontal
|
||||
// resolutions so it's OK to use constants and not precentage.
|
||||
// resolutions so it's OK to use constants and not percentage.
|
||||
bool isPal = false;
|
||||
if (height == FB_HEIGHT) {
|
||||
if (height == FB_HEIGHT)
|
||||
{
|
||||
ptrDiff += width * 47;
|
||||
height = 480;
|
||||
isPal = true;
|
||||
} else if (height == 288) {
|
||||
}
|
||||
else if (height == 288)
|
||||
{
|
||||
// TODO: This seems to be OK as is, but I might be wrong.
|
||||
isPal = true;
|
||||
}
|
||||
|
||||
if (isPal && width == FB_WIDTH) {
|
||||
if (isPal && width == FB_WIDTH)
|
||||
ptrDiff += 7;
|
||||
}
|
||||
|
||||
// The core handles vertical overscan for NTSC pretty well, but it ignores
|
||||
// horizontal overscan. This is a tough estimation of what the horizontal
|
||||
@ -324,6 +334,7 @@ void retro_run()
|
||||
ptr += ptrDiff;
|
||||
video_cb(ptr, width, height, FB_WIDTH << 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
video_frames++;
|
||||
audio_frames += spec.SoundBufSize;
|
||||
@ -337,19 +348,19 @@ void retro_get_system_info(struct retro_system_info *info)
|
||||
info->library_name = MEDNAFEN_CORE_NAME;
|
||||
info->library_version = "0.9.26";
|
||||
info->need_fullpath = true;
|
||||
info->valid_extensions = "cue|CUE";
|
||||
info->valid_extensions = MEDNAFEN_CORE_EXTENSIONS;
|
||||
}
|
||||
|
||||
void retro_get_system_av_info(struct retro_system_av_info *info)
|
||||
{
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->timing.fps = 59.85398; // Determined from empirical testing.
|
||||
info->timing.fps = MEDNAFEN_CORE_TIMING_FPS; // Determined from empirical testing.
|
||||
info->timing.sample_rate = 44100;
|
||||
info->geometry.base_width = 320;
|
||||
info->geometry.base_height = 240;
|
||||
info->geometry.max_width = 640;
|
||||
info->geometry.max_height = 480;
|
||||
info->geometry.aspect_ratio = 4.0 / 3.0;
|
||||
info->geometry.base_width = MEDNAFEN_CORE_GEOMETRY_BASE_W;
|
||||
info->geometry.base_height = MEDNAFEN_CORE_GEOMETRY_BASE_H;
|
||||
info->geometry.max_width = MEDNAFEN_CORE_GEOMETRY_MAX_W;
|
||||
info->geometry.max_height = MEDNAFEN_CORE_GEOMETRY_MAX_H;
|
||||
info->geometry.aspect_ratio = MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO;
|
||||
}
|
||||
|
||||
void retro_deinit()
|
||||
|
50
stubs.cpp
50
stubs.cpp
@ -4,7 +4,6 @@
|
||||
#include "mednafen/git.h"
|
||||
#include "mednafen/general.h"
|
||||
#include "mednafen/mednafen-driver.h"
|
||||
#include "thread.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -72,55 +71,6 @@ void MDFND_PrintError(const char* err)
|
||||
std::cerr << err;
|
||||
}
|
||||
|
||||
MDFN_Thread *MDFND_CreateThread(int (*fn)(void *), void *data)
|
||||
{
|
||||
return (MDFN_Thread*)sthread_create((void (*)(void*))fn, data);
|
||||
}
|
||||
|
||||
void MDFND_SetMovieStatus(StateStatusStruct *) {}
|
||||
void MDFND_SetStateStatus(StateStatusStruct *) {}
|
||||
|
||||
void MDFND_WaitThread(MDFN_Thread *thr, int *val)
|
||||
{
|
||||
sthread_join((sthread_t*)thr);
|
||||
|
||||
if (val)
|
||||
{
|
||||
*val = 0;
|
||||
std::cerr << "WaitThread relies on return value." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void MDFND_KillThread(MDFN_Thread *)
|
||||
{
|
||||
std::cerr << "Killing a thread is a BAD IDEA!" << std::endl;
|
||||
}
|
||||
|
||||
MDFN_Mutex *MDFND_CreateMutex()
|
||||
{
|
||||
return (MDFN_Mutex*)slock_new();
|
||||
}
|
||||
|
||||
void MDFND_DestroyMutex(MDFN_Mutex *lock)
|
||||
{
|
||||
slock_free((slock_t*)lock);
|
||||
}
|
||||
|
||||
int MDFND_LockMutex(MDFN_Mutex *lock)
|
||||
{
|
||||
slock_lock((slock_t*)lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MDFND_UnlockMutex(MDFN_Mutex *lock)
|
||||
{
|
||||
slock_unlock((slock_t*)lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MDFND_SendData(const void*, uint32) {}
|
||||
void MDFND_RecvData(void *, uint32) {}
|
||||
|
||||
uint32 MDFND_GetTime()
|
||||
{
|
||||
static bool first = true;
|
||||
|
50
stubs_thread.cpp
Normal file
50
stubs_thread.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include "mednafen/mednafen-types.h"
|
||||
#include "mednafen/mednafen.h"
|
||||
#include "mednafen/md5.h"
|
||||
#include "mednafen/git.h"
|
||||
#include "mednafen/general.h"
|
||||
#include "mednafen/mednafen-driver.h"
|
||||
#include "thread.h"
|
||||
|
||||
MDFN_Thread *MDFND_CreateThread(int (*fn)(void *), void *data)
|
||||
{
|
||||
return (MDFN_Thread*)sthread_create((void (*)(void*))fn, data);
|
||||
}
|
||||
|
||||
void MDFND_WaitThread(MDFN_Thread *thr, int *val)
|
||||
{
|
||||
sthread_join((sthread_t*)thr);
|
||||
|
||||
if (val)
|
||||
{
|
||||
*val = 0;
|
||||
fprintf(stderr, "WaitThread relies on return value.\n");
|
||||
}
|
||||
}
|
||||
|
||||
void MDFND_KillThread(MDFN_Thread *)
|
||||
{
|
||||
fprintf(stderr, "Killing a thread is a BAD IDEA!\n");
|
||||
}
|
||||
|
||||
MDFN_Mutex *MDFND_CreateMutex()
|
||||
{
|
||||
return (MDFN_Mutex*)slock_new();
|
||||
}
|
||||
|
||||
void MDFND_DestroyMutex(MDFN_Mutex *lock)
|
||||
{
|
||||
slock_free((slock_t*)lock);
|
||||
}
|
||||
|
||||
int MDFND_LockMutex(MDFN_Mutex *lock)
|
||||
{
|
||||
slock_lock((slock_t*)lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MDFND_UnlockMutex(MDFN_Mutex *lock)
|
||||
{
|
||||
slock_unlock((slock_t*)lock);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user