-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathstubs.cpp
123 lines (100 loc) · 2.08 KB
/
stubs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "mednafen/mednafen-types.h"
#include "mednafen/mednafen.h"
#include "mednafen/git.h"
#include "mednafen/general.h"
#include "mednafen/mednafen-driver.h"
#include "mednafen/netplay-driver.h"
#include "thread.h"
#include <iostream>
#ifdef _WIN32
#include <windows.h>
#else
#include <sys/time.h>
#endif
// Stubs
void MDFND_Sleep(unsigned int time)
{
#ifdef _WIN32
Sleep(time);
#else
usleep(time * 1000);
#endif
}
void MDFND_DispMessage(unsigned char *str)
{
std::cerr << str;
}
void MDFND_Message(const char *str)
{
std::cerr << str;
}
void MDFND_MidSync(const EmulateSpecStruct *)
{}
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;
}
int MDFND_SendData(const void*, uint32) { return 0; }
int MDFND_RecvData(void *, uint32) { return 0; }
void MDFND_NetplayText(const uint8*, bool) {}
void MDFND_NetworkClose() {}
uint32 MDFND_GetTime()
{
static bool first = true;
static uint32_t start_ms;
#ifdef _WIN32
DWORD ms = timeGetTime();
if (first)
{
start_ms = ms;
first = false;
}
#else
struct timeval val;
gettimeofday(&val, NULL);
uint32_t ms = val.tv_sec * 1000 + val.tv_usec / 1000;
if (first)
{
start_ms = ms;
first = false;
}
#endif
return ms - start_ms;
}