2016-01-07 08:14:33 +00:00
|
|
|
#pragma once
|
2010-08-09 13:28:56 +00:00
|
|
|
|
Update to v094r09 release.
byuu says:
This will easily be the biggest diff in the history of higan. And not in
a good way.
* target-higan and target-loki have been blown away completely
* nall and ruby massively updated
* phoenix replaced with hiro (pretty near a total rewrite)
* target-higan restarted using hiro (just a window for now)
* all emulation cores updated to compile again
* installation changed to not require root privileges (installs locally)
For the foreseeable future (maybe even permanently?), the new higan UI
will only build under Linux/BSD with GTK+ 2.20+. Probably the most
likely route for Windows/OS X will be to try and figure out how to build
hiro/GTK on those platforms, as awful as that would be. The other
alternative would be to produce new UIs for those platforms ... which
would actually be a good opportunity to make something much more user
friendly.
Being that I just started on this a few hours ago, that means that for
at least a few weeks, don't expect to be able to actually play any
games. Right now, you can pretty much just compile the binary and that's
it. It's quite possible that some nall changes didn't produce
compilation errors, but will produce runtime errors. So until the UI can
actually load games, we won't know if anything is broken. But we should
mostly be okay. It was mostly just trim<1> -> trim changes, moving to
Hash::SHA256 (much cleaner), and patching some reckless memory copy
functions enough to compile.
Progress isn't going to be like it was before: I'm now dividing my time
much thinner between studying and other hobbies.
My aim this time is not to produce a binary for everyone to play games
on. Rather, it's to keep the emulator alive. I want to be able to apply
critical patches again. And I would also like the base of the emulator
to live on, for use in other emulator frontends that utilize higan.
2015-02-26 10:10:46 +00:00
|
|
|
#include <nall/traits.hpp>
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
namespace nall {
|
2010-09-29 00:05:36 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
template<typename T> struct function;
|
2013-05-02 11:25:45 +00:00
|
|
|
|
2015-12-14 09:41:06 +00:00
|
|
|
template<typename R, typename... P> struct function<auto (P...) -> R> {
|
2018-08-04 11:44:00 +00:00
|
|
|
using cast = auto (*)(P...) -> R;
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
//value = true if auto L::operator()(P...) -> R exists
|
|
|
|
template<typename L> struct is_compatible {
|
|
|
|
template<typename T> static auto exists(T*) -> const typename is_same<R, decltype(declval<T>().operator()(declval<P>()...))>::type;
|
|
|
|
template<typename T> static auto exists(...) -> const false_type;
|
|
|
|
static constexpr bool value = decltype(exists<L>(0))::value;
|
|
|
|
};
|
|
|
|
|
Update to v100r08 release.
byuu says:
Six and a half hours this time ... one new opcode, and all old opcodes
now in a deprecated format. Hooray, progress!
For building the table, I've decided to move from:
for(uint opcode : range(65536)) {
if(match(...)) bind(opNAME, ...);
}
To instead having separate for loops for each supported opcode. This
lets me specialize parts I want with templates.
And to this aim, I'm moving to replace all of the
(read,write)(size, ...) functions with (read,write)<Size>(...) functions.
This will amount to the ~70ish instructions being triplicated ot ~210ish
instructions; but I think this is really important.
When I was getting into flag calculations, a ton of conditionals
were needed to mask sizes to byte/word/long. There was also lots of
conditionals in all the memory access handlers.
The template code is ugly, but we eliminate a huge amount of branch
conditions this way.
2016-07-17 22:11:29 +00:00
|
|
|
function() {}
|
2015-07-14 09:32:43 +00:00
|
|
|
function(const function& source) { operator=(source); }
|
|
|
|
function(auto (*function)(P...) -> R) { callback = new global(function); }
|
|
|
|
template<typename C> function(auto (C::*function)(P...) -> R, C* object) { callback = new member<C>(function, object); }
|
|
|
|
template<typename C> function(auto (C::*function)(P...) const -> R, C* object) { callback = new member<C>((auto (C::*)(P...) -> R)function, object); }
|
2016-10-27 21:16:58 +00:00
|
|
|
template<typename L, typename = enable_if_t<is_compatible<L>::value>> function(const L& object) { callback = new lambda<L>(object); }
|
2018-08-04 11:44:00 +00:00
|
|
|
explicit function(void* function) { if(function) callback = new global((auto (*)(P...) -> R)function); }
|
2015-07-14 09:32:43 +00:00
|
|
|
~function() { if(callback) delete callback; }
|
|
|
|
|
|
|
|
explicit operator bool() const { return callback; }
|
|
|
|
auto operator()(P... p) const -> R { return (*callback)(forward<P>(p)...); }
|
|
|
|
auto reset() -> void { if(callback) { delete callback; callback = nullptr; } }
|
|
|
|
|
|
|
|
auto operator=(const function& source) -> function& {
|
|
|
|
if(this != &source) {
|
|
|
|
if(callback) { delete callback; callback = nullptr; }
|
|
|
|
if(source.callback) callback = source.callback->copy();
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2018-08-04 11:44:00 +00:00
|
|
|
auto operator=(void* source) -> function& {
|
|
|
|
if(callback) { delete callback; callback = nullptr; }
|
|
|
|
callback = new global((auto (*)(P...) -> R)source);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
private:
|
2013-05-02 11:25:45 +00:00
|
|
|
struct container {
|
2015-07-14 09:32:43 +00:00
|
|
|
virtual auto operator()(P... p) const -> R = 0;
|
|
|
|
virtual auto copy() const -> container* = 0;
|
|
|
|
virtual ~container() = default;
|
2013-05-02 11:25:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
container* callback = nullptr;
|
|
|
|
|
|
|
|
struct global : container {
|
2015-07-14 09:32:43 +00:00
|
|
|
auto (*function)(P...) -> R;
|
|
|
|
auto operator()(P... p) const -> R { return function(forward<P>(p)...); }
|
|
|
|
auto copy() const -> container* { return new global(function); }
|
|
|
|
global(auto (*function)(P...) -> R) : function(function) {}
|
2013-05-02 11:25:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template<typename C> struct member : container {
|
2015-07-14 09:32:43 +00:00
|
|
|
auto (C::*function)(P...) -> R;
|
2013-05-02 11:25:45 +00:00
|
|
|
C* object;
|
2015-07-14 09:32:43 +00:00
|
|
|
auto operator()(P... p) const -> R { return (object->*function)(forward<P>(p)...); }
|
|
|
|
auto copy() const -> container* { return new member(function, object); }
|
|
|
|
member(auto (C::*function)(P...) -> R, C* object) : function(function), object(object) {}
|
2010-08-09 13:28:56 +00:00
|
|
|
};
|
2013-05-02 11:25:45 +00:00
|
|
|
|
|
|
|
template<typename L> struct lambda : container {
|
|
|
|
mutable L object;
|
2015-07-14 09:32:43 +00:00
|
|
|
auto operator()(P... p) const -> R { return object(forward<P>(p)...); }
|
|
|
|
auto copy() const -> container* { return new lambda(object); }
|
2013-05-02 11:25:45 +00:00
|
|
|
lambda(const L& object) : object(object) {}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|