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.
This commit is contained in:
Tim Allen
2015-02-26 21:10:46 +11:00
parent 1a7bc6bb87
commit a512d14628
793 changed files with 20182 additions and 19416 deletions

View File

@@ -2,46 +2,107 @@
namespace nall {
string substr(rstring source, unsigned offset, unsigned length) {
auto string::read(const string& filename) -> string {
#if !defined(_WIN32)
FILE* fp = fopen(filename, "rb");
#else
FILE* fp = _wfopen(utf16_t(filename), L"rb");
#endif
string result;
if(length == ~0u) length = source.size() - offset;
result.resize(length);
memcpy(result.data(), source.data() + offset, length);
if(!fp) return result;
fseek(fp, 0, SEEK_END);
signed filesize = ftell(fp);
if(filesize < 0) return fclose(fp), result;
rewind(fp);
result.resize(filesize);
fread(result.pointer(), 1, filesize, fp);
return fclose(fp), result;
}
template<unsigned L> auto string::repeat(const string& pattern) -> string {
string result;
unsigned times = L;
while(times--) result.append(pattern);
return result;
}
string sha256(const uint8_t* data, unsigned size) {
sha256_ctx sha;
uint8_t hash[32];
sha256_init(&sha);
sha256_chunk(&sha, data, size);
sha256_final(&sha);
sha256_hash(&sha, hash);
string result;
for(auto& byte : hash) result.append(hex<2>(byte));
auto fill(string& self, char fill) -> string& {
memory::fill(self.pointer(), self.size(), fill);
return self;
}
auto hash(const string& self) -> unsigned {
const char* p = self.data();
unsigned size = self.size();
unsigned result = 5381;
while(size--) result = (result << 5) + result + *p++;
return result;
}
bool tokenize(lstring& list, const char* s, const char* p) {
while(*s) {
if(*p == '*') {
const char* b = s;
while(*s) {
if(tokenize(list, s++, p + 1)) {
list.prepend(substr(b, 0, --s - b));
return true;
}
}
list.prepend(b);
return !*++p;
}
if(*s++ != *p++) return false;
auto remove(string& self, unsigned offset, unsigned length) -> string& {
char* p = self.pointer();
length = min(length, self.size());
memory::move(p + offset, p + offset + length, self.size() - length);
return self.resize(self.size() - length);
}
auto reverse(string& self) -> string& {
char* p = self.pointer();
unsigned size = self.size();
unsigned pivot = size >> 1;
for(signed x = 0, y = size - 1; x < pivot && y >= 0; x++, y--) std::swap(p[x], p[y]);
return self;
}
//+length => insert/delete from start (right justify)
//-length => insert/delete from end (left justify)
auto size(string& self, signed length, char fill) -> string& {
unsigned size = self.size();
if(size == length) return self;
bool right = length >= 0;
length = abs(length);
if(size < length) { //expand
self.resize(length);
char* p = self.pointer();
unsigned displacement = length - size;
if(right) memory::move(p + displacement, p, size);
else p += size;
while(displacement--) *p++ = fill;
} else { //shrink
char* p = self.pointer();
unsigned displacement = size - length;
if(right) memory::move(p, p + displacement, length);
self.resize(length);
}
while(*p == '*') { list.prepend(s); p++; }
return !*p;
return self;
}
char* integer(char* result, intmax_t value) {
auto slice(const string& self, signed offset, signed length) -> string {
string result;
if(offset < self.size()) {
if(length < 0) length = self.size() - offset;
result.resize(length);
memory::copy(result.pointer(), self.data() + offset, length);
}
return result;
}
//legacy function: required for some library functions, do not use in newly written code
auto substr(rstring source, signed offset, signed length) -> string {
string result;
if(length < 0) length = source.size() - offset;
result.resize(length);
memory::copy(result.pointer(), source.data() + offset, length);
return result;
}
auto integer(char* result, intmax_t value) -> char* {
bool negative = value < 0;
if(negative) value = -value;
@@ -54,14 +115,13 @@ char* integer(char* result, intmax_t value) {
value /= 10;
} while(value);
if(negative) buffer[size++] = '-';
//buffer[size++] = negative ? '-' : '+';
for(signed x = size - 1, y = 0; x >= 0 && y < size; x--, y++) result[x] = buffer[y];
result[size] = 0;
return result;
}
char* decimal(char* result, uintmax_t value) {
auto decimal(char* result, uintmax_t value) -> char* {
char buffer[64];
unsigned size = 0;
@@ -79,7 +139,7 @@ char* decimal(char* result, uintmax_t value) {
//using sprintf is certainly not the most ideal method to convert
//a double to a string ... but attempting to parse a double by
//hand, digit-by-digit, results in subtle rounding errors.
unsigned real(char* str, long double value) {
auto real(char* result, long double value) -> unsigned {
char buffer[256];
#ifdef _WIN32
//Windows C-runtime does not support long double via sprintf()
@@ -101,17 +161,10 @@ unsigned real(char* str, long double value) {
}
unsigned length = strlen(buffer);
if(str) strcpy(str, buffer);
if(result) strcpy(result, buffer);
return length + 1;
}
string real(long double value) {
string temp;
temp.resize(real(nullptr, value));
real(temp.data(), value);
return temp;
}
}
#endif