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

View File

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

View File

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

View File

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

View File

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