Update to purify v03 release.

byuu says:

This release has an updated version of ananke. If you replace the higan
v092 ananke.dll with this new one, it will fix the SGB+TG3000+ToP+DKJM2
loading issues.
This commit is contained in:
Tim Allen 2013-01-21 19:57:04 +11:00
parent a7c35a65b4
commit 65c4011bec
5 changed files with 120 additions and 36 deletions

View File

@ -6,38 +6,79 @@
#include <nall/intrinsics.hpp>
#if defined(PLATFORM_X) || defined(PLATFORM_OSX)
#include <thread>
#elif defined(PLATFORM_WIN)
#include <pthread.h>
//TDM/GCC 4.7 does not support std::thread
//implement an extremely lightweight wrapper
namespace std {
inline DWORD WINAPI thread_entry_point(LPVOID parameter);
namespace nall {
void* thread_entry_point(void*);
struct thread {
bool joinable() const {
return active == false;
thread(function<void ()> entryPoint) : entryPoint(entryPoint), completed(false), dead(false) {
pthread_create(&pthread, NULL, thread_entry_point, (void*)this);
}
~thread() {
join();
}
bool active() const {
return completed == false;
}
void join() {
while(active) usleep(1);
}
thread(function<void ()> entryPoint) : entryPoint(entryPoint), active(true) {
CreateThread(NULL, 0, thread_entry_point, (void*)this, 0, NULL);
if(dead) return;
dead = true;
pthread_join(pthread, NULL);
}
private:
pthread_t pthread;
function<void ()> entryPoint;
bool active;
volatile bool completed, dead;
friend void* thread_entry_point(void*);
};
void* thread_entry_point(void *parameter) {
thread *context = (thread*)parameter;
context->entryPoint();
context->completed = true;
pthread_exit(0);
}
}
#elif defined(PLATFORM_WIN)
namespace nall {
inline DWORD WINAPI thread_entry_point(LPVOID);
struct thread {
thread(function<void ()> entryPoint) : entryPoint(entryPoint), completed(false), dead(false) {
hthread = CreateThread(NULL, 0, thread_entry_point, (void*)this, 0, NULL);
}
~thread() {
join();
}
bool active() const {
return completed == false;
}
void join() {
if(dead) return;
dead = true;
WaitForSingleObject(hthread, INFINITE);
CloseHandle(hthread);
}
private:
HANDLE hthread;
function<void ()> entryPoint;
volatile bool completed, dead;
friend DWORD WINAPI thread_entry_point(LPVOID);
};
inline DWORD WINAPI thread_entry_point(LPVOID parameter) {
thread *context = (thread*)parameter;
context->entryPoint();
context->active = false;
context->completed = true;
return 0;
}
}

View File

@ -139,6 +139,8 @@ string Ananke::openSuperFamicom(vector<uint8_t> &buffer) {
}
string Ananke::syncSuperFamicom(const string &pathname) {
if(file::exists({pathname, "msu1.rom"})) return ""; //cannot update MSU1 games
vector<uint8_t> buffer;
auto append = [&](string filename) {

View File

@ -22,7 +22,7 @@ obj/purify.o: purify.cpp
build: $(objects)
ifeq ($(platform),x)
$(cpp) $(link) -o purify $(objects) $(phoenixlink)
$(cpp) -pthread $(link) -o purify $(objects) $(phoenixlink)
else ifeq ($(platform),win)
windres phoenix/windows/phoenix.rc obj/phoenix-resource.o
$(cpp) -shared -o phoenix.dll obj/phoenix.o $(phoenixlink)

View File

@ -6,38 +6,79 @@
#include <nall/intrinsics.hpp>
#if defined(PLATFORM_X) || defined(PLATFORM_OSX)
#include <thread>
#elif defined(PLATFORM_WIN)
#include <pthread.h>
//TDM/GCC 4.7 does not support std::thread
//implement an extremely lightweight wrapper
namespace std {
inline DWORD WINAPI thread_entry_point(LPVOID parameter);
namespace nall {
void* thread_entry_point(void*);
struct thread {
bool joinable() const {
return active == false;
thread(function<void ()> entryPoint) : entryPoint(entryPoint), completed(false), dead(false) {
pthread_create(&pthread, NULL, thread_entry_point, (void*)this);
}
~thread() {
join();
}
bool active() const {
return completed == false;
}
void join() {
while(active) usleep(1);
}
thread(function<void ()> entryPoint) : entryPoint(entryPoint), active(true) {
CreateThread(NULL, 0, thread_entry_point, (void*)this, 0, NULL);
if(dead) return;
dead = true;
pthread_join(pthread, NULL);
}
private:
pthread_t pthread;
function<void ()> entryPoint;
bool active;
volatile bool completed, dead;
friend void* thread_entry_point(void*);
};
void* thread_entry_point(void *parameter) {
thread *context = (thread*)parameter;
context->entryPoint();
context->completed = true;
pthread_exit(0);
}
}
#elif defined(PLATFORM_WIN)
namespace nall {
inline DWORD WINAPI thread_entry_point(LPVOID);
struct thread {
thread(function<void ()> entryPoint) : entryPoint(entryPoint), completed(false), dead(false) {
hthread = CreateThread(NULL, 0, thread_entry_point, (void*)this, 0, NULL);
}
~thread() {
join();
}
bool active() const {
return completed == false;
}
void join() {
if(dead) return;
dead = true;
WaitForSingleObject(hthread, INFINITE);
CloseHandle(hthread);
}
private:
HANDLE hthread;
function<void ()> entryPoint;
volatile bool completed, dead;
friend DWORD WINAPI thread_entry_point(LPVOID);
};
inline DWORD WINAPI thread_entry_point(LPVOID parameter) {
thread *context = (thread*)parameter;
context->entryPoint();
context->active = false;
context->completed = true;
return 0;
}
}

View File

@ -42,7 +42,7 @@ Application::Application() {
}
setFrameGeometry({64, 64, 720, 480});
setTitle("purify v02.01");
setTitle("purify v03");
layout.setMargin(5);
pathLabel.setText("Path:");
@ -181,8 +181,8 @@ void Application::purify() {
OS::processEvents();
PurifyContext purifyContext(purifyList);
std::thread purifyThread([&] { purifyContext.run(); });
while(purifyContext.position < purifyContext.size) {
nall::thread purifyThread([&] { purifyContext.run(); });
while(purifyThread.active()) {
OS::processEvents();
unsigned position = ((unsigned)(double)purifyContext.position / (double)purifyContext.size * 100.0 + 0.5);
progressBar.setPosition(position);