Skip to content

Commit

Permalink
1.22.x API changes and cleanup unused stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
clobber committed Jun 6, 2019
1 parent 353dca2 commit 6119f5b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 151 deletions.
2 changes: 0 additions & 2 deletions Mednafen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@
8CB3E08417F1DE5E0090372A /* tcache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CB3DCA217F1DE5E0090372A /* tcache.cpp */; };
8CB3E08717F1DE5E0090372A /* v30mz.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CB3DCA617F1DE5E0090372A /* v30mz.cpp */; };
8CB3E0AB17F1FAD00090372A /* stubs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94454E3B17852E61006C057B /* stubs.cpp */; };
8CB3E0AC17F1FAD20090372A /* thread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94454E3617852E44006C057B /* thread.cpp */; };
8CB3E0AE17F20E6D0090372A /* netplay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CB3D7C417F1DE5B0090372A /* netplay.cpp */; };
8CB3E0B117F20EF10090372A /* scsicd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CB3D53C17F1DE5A0090372A /* scsicd.cpp */; };
8CB3E0B317F20F010090372A /* CDAccess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CB3D52417F1DE5A0090372A /* CDAccess.cpp */; };
Expand Down Expand Up @@ -4509,7 +4508,6 @@
8CB3DE9F17F1DE5E0090372A /* irq.cpp in Sources */,
8CB3DE8C17F1DE5E0090372A /* dis.cpp in Sources */,
8CB3DEA917F1DE5E0090372A /* spu.cpp in Sources */,
8CB3E0AC17F1FAD20090372A /* thread.cpp in Sources */,
8CB3E07517F1DE5E0090372A /* dis_groups.cpp in Sources */,
8CB3E0D517F212490090372A /* memory.cpp in Sources */,
8CB3E0EB17F2140E0090372A /* qtrecord.cpp in Sources */,
Expand Down
9 changes: 7 additions & 2 deletions MednafenGameCore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2955,7 +2955,7 @@ - (BOOL)loadFileAtPath:(NSString *)path error:(NSError **)error

[self initializeMednafen];

game = MDFNI_LoadGame(_mednafenCoreModule.UTF8String, path.fileSystemRepresentation);
game = MDFNI_LoadGame(_mednafenCoreModule.UTF8String, &::Mednafen::NVFS, path.fileSystemRepresentation);

if(!game)
return NO;
Expand Down Expand Up @@ -3126,6 +3126,11 @@ - (BOOL)loadFileAtPath:(NSString *)path error:(NSError **)error

game->SetInput(12, "builtin", (uint8_t *)_inputBuffer[12]); // reset button status
}
else if ([_mednafenCoreModule isEqualToString:@"vb"])
{
game->SetInput(0, "gamepad", (uint8_t *)_inputBuffer[0]);
game->SetInput(1, "misc", (uint8_t *)_inputBuffer[1]); // low battery sensor bit, unused currently
}
else
{
game->SetInput(0, "gamepad", (uint8_t *)_inputBuffer[0]);
Expand All @@ -3148,7 +3153,7 @@ - (void)executeFrame

memset(rects, 0, game->fb_height*sizeof(int32));

EmulateSpecStruct spec = {0};
EmulateSpecStruct spec;
spec.surface = surf;
spec.SoundRate = _sampleRate;
spec.SoundBuf = sound_buf;
Expand Down
156 changes: 9 additions & 147 deletions stubs.cpp
Original file line number Diff line number Diff line change
@@ -1,154 +1,16 @@
#include "mednafen/types.h"
#include "mednafen/git.h"
#include "mednafen.h"
#include "mednafen/mednafen-driver.h"
#include "thread.h"
#include "driver.h"

#include <iostream>
#include <sys/time.h>
#include <unistd.h>
#include <dispatch/dispatch.h>
void Mednafen::MDFND_OutputNotice(MDFN_NoticeType t, const char* s) noexcept {}

void MDFND_Sleep(unsigned int time)
{
usleep(time * 1000);
}
void Mednafen::MDFND_OutputInfo(const char *s) noexcept {}

void MDFND_OutputNotice(MDFN_NoticeType t, const char* s) noexcept
{}
void Mednafen::MDFND_MidSync(const EmulateSpecStruct *) {}

void MDFND_OutputInfo(const char *s) noexcept
{}
void Mednafen::MDFND_MediaSetNotification(uint32 drive_idx, uint32 state_idx, uint32 media_idx, uint32 orientation_idx) {}

void MDFND_MidSync(const EmulateSpecStruct *)
{}
bool Mednafen::MDFND_CheckNeedExit(void) { return false; }

void MDFND_MediaSetNotification(uint32 drive_idx, uint32 state_idx, uint32 media_idx, uint32 orientation_idx)
{}
void Mednafen::MDFND_NetplayText(const char* text, bool NetEcho) {}
void Mednafen::MDFND_NetplaySetHints(bool active, bool behind, uint32 local_players_mask) {}

void MDFND_NetplayText(const char* text, bool NetEcho)
{}

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;
}

MDFN_Cond* MDFND_CreateCond(void)
{
return (MDFN_Cond*)scond_new();
}

void MDFND_DestroyCond(MDFN_Cond* cond)
{
scond_free((scond_t*)cond);
}

int MDFND_SignalCond(MDFN_Cond* cond)
{
scond_signal((scond_t*)cond);
return 0;
}

int MDFND_WaitCond(MDFN_Cond* cond, MDFN_Mutex* mutex)
{
scond_wait((scond_t*)cond, (slock_t*)mutex);
return 0;
}

MDFN_Sem* MDFND_CreateSem(void)
{
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
return (MDFN_Sem*)sem;
}

void MDFND_DestroySem(MDFN_Sem* sem)
{
dispatch_release((dispatch_object_t)sem);
}

int MDFND_PostSem(MDFN_Sem* sem)
{
dispatch_semaphore_signal((dispatch_semaphore_t)sem);
return 0;
}

int MDFND_WaitSem(MDFN_Sem* sem)
{
dispatch_semaphore_wait((dispatch_semaphore_t)sem, DISPATCH_TIME_FOREVER);
return 0;
}

int MDFND_WaitSemTimeout(MDFN_Sem* sem, unsigned ms)
{
dispatch_time_t waitTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(ms * NSEC_PER_MSEC));
dispatch_semaphore_wait((dispatch_semaphore_t)sem, waitTime);
return 0;
}

void MDFND_SendData(const void*, uint32) {}
void MDFND_RecvData(void *, uint32) {}
void MDFND_NetplayText(const uint8*, bool) {}
void MDFND_NetworkClose() {}
void MDFND_NetplaySetHints(bool active, bool behind, uint32 local_players_mask) {}
int MDFND_NetworkConnect() { return 0; }
bool MDFND_CheckNeedExit(void) { return false; }

uint32 MDFND_GetTime()
{
static bool first = true;
static uint32_t start_ms;

struct timeval val;
gettimeofday(&val, NULL);
uint32_t ms = val.tv_sec * 1000 + val.tv_usec / 1000;

if(first)
{
start_ms = ms;
first = false;
}

return ms - start_ms;
}
void Mednafen::MDFND_SetStateStatus(StateStatusStruct *status) noexcept {}

0 comments on commit 6119f5b

Please sign in to comment.