mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-03 03:22:40 +02:00
Update to v094r38 release.
byuu says: I'll post more detailed changes later, but basically: - fixed Baldur's Gate bug - guess if no flash ROM ID present (fixes Magical Vacation, many many others) - nall cleanups - sfc/cartridge major cleanups - bsxcartridge/"bsx" renamed to mcc/"mcc" after the logic chip it uses (consistency with SGB/ICD2) - ... and more!
This commit is contained in:
@@ -22,7 +22,7 @@ namespace nall {
|
||||
string::string() : _data(nullptr), _capacity(SSO - 1), _size(0) {
|
||||
}
|
||||
|
||||
auto string::pointer() -> char* {
|
||||
auto string::get() -> char* {
|
||||
if(_capacity < SSO) return _text;
|
||||
if(*_refs > 1) _copy();
|
||||
return _data;
|
||||
@@ -59,7 +59,7 @@ auto string::reserve(unsigned capacity) -> type& {
|
||||
|
||||
auto string::resize(unsigned size) -> type& {
|
||||
reserve(size);
|
||||
pointer()[_size = size] = 0;
|
||||
get()[_size = size] = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,7 @@ namespace nall {
|
||||
string::string() : _data(nullptr), _refs(nullptr), _capacity(0), _size(0) {
|
||||
}
|
||||
|
||||
auto string::pointer() -> char* {
|
||||
auto string::get() -> char* {
|
||||
static char _null[] = "";
|
||||
if(!_data) return _null;
|
||||
if(*_refs > 1) _data = _copy(); //make unique for write operations
|
||||
@@ -38,7 +38,7 @@ auto string::reserve(unsigned capacity) -> type& {
|
||||
|
||||
auto string::resize(unsigned size) -> type& {
|
||||
reserve(size);
|
||||
pointer()[_size = size] = 0;
|
||||
get()[_size = size] = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@ string::string() {
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
auto string::pointer() -> char* {
|
||||
auto string::get() -> char* {
|
||||
if(_capacity < SSO) return _text;
|
||||
return _data;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ auto string::reserve(unsigned capacity) -> type& {
|
||||
|
||||
auto string::resize(unsigned size) -> type& {
|
||||
reserve(size);
|
||||
pointer()[_size = size] = 0;
|
||||
get()[_size = size] = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ cons:
|
||||
|
||||
namespace nall {
|
||||
|
||||
auto string::pointer() -> char* {
|
||||
auto string::get() -> char* {
|
||||
if(_capacity == 0) reserve(1);
|
||||
return _data;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ auto string::reserve(unsigned capacity) -> type& {
|
||||
|
||||
auto string::resize(unsigned size) -> type& {
|
||||
reserve(size);
|
||||
pointer()[_size = size] = 0;
|
||||
get()[_size = size] = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@@ -182,7 +182,7 @@ protected:
|
||||
|
||||
public:
|
||||
inline string();
|
||||
inline auto pointer() -> char*;
|
||||
inline auto get() -> char*;
|
||||
inline auto data() const -> const char*;
|
||||
inline auto reset() -> type&;
|
||||
inline auto reserve(unsigned) -> type&;
|
||||
@@ -214,8 +214,8 @@ public:
|
||||
string(const string& source) : string() { operator=(source); }
|
||||
string(string&& source) : string() { operator=(std::move(source)); }
|
||||
|
||||
auto begin() -> char* { return &pointer()[0]; }
|
||||
auto end() -> char* { return &pointer()[size()]; }
|
||||
auto begin() -> char* { return &get()[0]; }
|
||||
auto end() -> char* { return &get()[size()]; }
|
||||
auto begin() const -> const char* { return &data()[0]; }
|
||||
auto end() const -> const char* { return &data()[size()]; }
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
namespace nall {
|
||||
|
||||
auto downcase(string& self) -> string& {
|
||||
char* p = self.pointer();
|
||||
char* p = self.get();
|
||||
for(unsigned n = 0; n < self.size(); n++) {
|
||||
if(p[n] >= 'A' && p[n] <= 'Z') p[n] += 0x20;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ auto downcase(string& self) -> string& {
|
||||
}
|
||||
|
||||
auto qdowncase(string& self) -> string& {
|
||||
char* p = self.pointer();
|
||||
char* p = self.get();
|
||||
for(unsigned n = 0, quoted = 0; n < self.size(); n++) {
|
||||
if(p[n] == '\"') quoted ^= 1;
|
||||
if(!quoted && p[n] >= 'A' && p[n] <= 'Z') p[n] += 0x20;
|
||||
@@ -20,7 +20,7 @@ auto qdowncase(string& self) -> string& {
|
||||
}
|
||||
|
||||
auto upcase(string& self) -> string& {
|
||||
char* p = self.pointer();
|
||||
char* p = self.get();
|
||||
for(unsigned n = 0; n < self.size(); n++) {
|
||||
if(p[n] >= 'a' && p[n] <= 'z') p[n] -= 0x20;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ auto upcase(string& self) -> string& {
|
||||
}
|
||||
|
||||
auto qupcase(string& self) -> string& {
|
||||
char* p = self.pointer();
|
||||
char* p = self.get();
|
||||
for(unsigned n = 0, quoted = 0; n < self.size(); n++) {
|
||||
if(p[n] == '\"') quoted ^= 1;
|
||||
if(!quoted && p[n] >= 'a' && p[n] <= 'z') p[n] -= 0x20;
|
||||
@@ -38,7 +38,7 @@ auto qupcase(string& self) -> string& {
|
||||
|
||||
auto transform(string& self, rstring from, rstring to) -> string& {
|
||||
if(from.size() != to.size() || from.size() == 0) return self; //patterns must be the same length
|
||||
char* p = self.pointer();
|
||||
char* p = self.get();
|
||||
for(unsigned n = 0; n < self.size(); n++) {
|
||||
for(unsigned s = 0; s < from.size(); s++) {
|
||||
if(p[n] == from[s]) {
|
||||
|
@@ -43,7 +43,7 @@ template<typename T> auto _append(string& self, const stringify<T>& source) -> s
|
||||
unsigned size = self.size();
|
||||
unsigned length = source.size();
|
||||
self.resize(size + length);
|
||||
memory::copy(self.pointer() + size, source.data(), length);
|
||||
memory::copy(self.get() + size, source.data(), length);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,7 @@ auto string::format(const nall::format& params) -> type& {
|
||||
}
|
||||
|
||||
resize(size);
|
||||
memory::copy(pointer(), data, size);
|
||||
memory::copy(get(), data, size);
|
||||
memory::free(data);
|
||||
return *this;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ template<typename... P> auto print(P&&... p) -> void {
|
||||
auto integer(intmax_t value, long precision, char padchar) -> string {
|
||||
string buffer;
|
||||
buffer.resize(1 + sizeof(intmax_t) * 3);
|
||||
char* p = buffer.pointer();
|
||||
char* p = buffer.get();
|
||||
|
||||
bool negative = value < 0;
|
||||
value = abs(value);
|
||||
@@ -95,7 +95,7 @@ auto integer(intmax_t value, long precision, char padchar) -> string {
|
||||
auto decimal(uintmax_t value, long precision, char padchar) -> string {
|
||||
string buffer;
|
||||
buffer.resize(sizeof(uintmax_t) * 3);
|
||||
char* p = buffer.pointer();
|
||||
char* p = buffer.get();
|
||||
|
||||
unsigned size = 0;
|
||||
do {
|
||||
@@ -111,7 +111,7 @@ auto decimal(uintmax_t value, long precision, char padchar) -> string {
|
||||
auto hex(uintmax_t value, long precision, char padchar) -> string {
|
||||
string buffer;
|
||||
buffer.resize(sizeof(uintmax_t) * 2);
|
||||
char* p = buffer.pointer();
|
||||
char* p = buffer.get();
|
||||
|
||||
unsigned size = 0;
|
||||
do {
|
||||
@@ -128,7 +128,7 @@ auto hex(uintmax_t value, long precision, char padchar) -> string {
|
||||
auto octal(uintmax_t value, long precision, char padchar) -> string {
|
||||
string buffer;
|
||||
buffer.resize(sizeof(uintmax_t) * 3);
|
||||
char* p = buffer.pointer();
|
||||
char* p = buffer.get();
|
||||
|
||||
unsigned size = 0;
|
||||
do {
|
||||
@@ -144,7 +144,7 @@ auto octal(uintmax_t value, long precision, char padchar) -> string {
|
||||
auto binary(uintmax_t value, long precision, char padchar) -> string {
|
||||
string buffer;
|
||||
buffer.resize(sizeof(uintmax_t) * 8);
|
||||
char* p = buffer.pointer();
|
||||
char* p = buffer.get();
|
||||
|
||||
unsigned size = 0;
|
||||
do {
|
||||
@@ -170,7 +170,7 @@ auto pointer(uintptr_t value, long precision) -> string {
|
||||
auto real(long double value) -> string {
|
||||
string temp;
|
||||
temp.resize(real(nullptr, value));
|
||||
real(temp.pointer(), value);
|
||||
real(temp.get(), value);
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
@@ -109,7 +109,7 @@ protected:
|
||||
auto parse(string document) -> void {
|
||||
//in order to simplify the parsing logic; we do an initial pass to normalize the data
|
||||
//the below code will turn '\r\n' into '\n'; skip empty lines; and skip comment lines
|
||||
char* p = document.pointer(), *output = p;
|
||||
char* p = document.get(), *output = p;
|
||||
while(*p) {
|
||||
char* origin = p;
|
||||
bool empty = true;
|
||||
|
@@ -52,7 +52,7 @@ protected:
|
||||
return;
|
||||
#endif
|
||||
|
||||
char* output = target.pointer();
|
||||
char* output = target.get();
|
||||
while(length) {
|
||||
if(*source == '&') {
|
||||
if(!memory::compare(source, "<", 4)) { *output++ = '<'; source += 4; length -= 4; continue; }
|
||||
|
@@ -48,10 +48,11 @@ auto basename(const string& self) -> string {
|
||||
// /parent/child.type/(name).type
|
||||
auto prefixname(const string& self) -> string {
|
||||
const char* p = self.data() + self.size() - 1, *last = p;
|
||||
for(signed offset = self.size() - 1, suffix = 0; offset >= 0; offset--, p--) {
|
||||
for(signed offset = self.size() - 1, suffix = -1; offset >= 0; offset--, p--) {
|
||||
if(*p == '/' && p == last) continue;
|
||||
if(*p == '/') return slice(self, offset + 1, suffix ? suffix - offset - 1 : 0).rtrim("/");
|
||||
if(*p == '.' && suffix == 0) suffix = offset;
|
||||
if(*p == '/') return slice(self, offset + 1, suffix >= 0 ? suffix - offset - 1 : 0).rtrim("/");
|
||||
if(*p == '.' && suffix == -1) { suffix = offset; continue; }
|
||||
if(offset == 0) return slice(self, offset, suffix).rtrim("/");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ auto _replace(string& self, rstring from, rstring to, long limit) -> string& {
|
||||
|
||||
//in-place overwrite
|
||||
if(to.size() == from.size()) {
|
||||
char* p = self.pointer();
|
||||
char* p = self.get();
|
||||
|
||||
for(signed n = 0, remaining = matches, quoted = 0; n <= size - (signed)from.size();) {
|
||||
if(Quoted) { if(p[n] == '\"') { quoted ^= 1; n++; continue; } if(quoted) { n++; continue; } }
|
||||
@@ -40,7 +40,7 @@ auto _replace(string& self, rstring from, rstring to, long limit) -> string& {
|
||||
|
||||
//left-to-right shrink
|
||||
else if(to.size() < from.size()) {
|
||||
char* p = self.pointer();
|
||||
char* p = self.get();
|
||||
signed offset = 0;
|
||||
signed base = 0;
|
||||
|
||||
@@ -64,7 +64,7 @@ auto _replace(string& self, rstring from, rstring to, long limit) -> string& {
|
||||
//right-to-left expand
|
||||
else if(to.size() > from.size()) {
|
||||
self.resize(size + matches * (to.size() - from.size()));
|
||||
char* p = self.pointer();
|
||||
char* p = self.get();
|
||||
|
||||
signed offset = self.size();
|
||||
signed base = size;
|
||||
|
@@ -18,7 +18,7 @@ template<bool Insensitive, bool Quoted> auto _split(lstring& self, rstring sourc
|
||||
|
||||
string& s = self(matches);
|
||||
s.resize(n - base);
|
||||
memory::copy(s.pointer(), p + base, n - base);
|
||||
memory::copy(s.get(), p + base, n - base);
|
||||
|
||||
n += find.size();
|
||||
base = n;
|
||||
@@ -27,7 +27,7 @@ template<bool Insensitive, bool Quoted> auto _split(lstring& self, rstring sourc
|
||||
|
||||
string& s = self(matches);
|
||||
s.resize(size - base);
|
||||
memory::copy(s.pointer(), p + base, size - base);
|
||||
memory::copy(s.get(), p + base, size - base);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ auto string::read(const string& filename) -> string {
|
||||
|
||||
rewind(fp);
|
||||
result.resize(filesize);
|
||||
fread(result.pointer(), 1, filesize, fp);
|
||||
auto unused = fread(result.get(), 1, filesize, fp);
|
||||
return fclose(fp), result;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ auto string::repeat(const string& pattern, unsigned times) -> string {
|
||||
}
|
||||
|
||||
auto fill(string& self, char fill) -> string& {
|
||||
memory::fill(self.pointer(), self.size(), fill);
|
||||
memory::fill(self.get(), self.size(), fill);
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -42,14 +42,14 @@ auto hash(const string& self) -> unsigned {
|
||||
}
|
||||
|
||||
auto remove(string& self, unsigned offset, unsigned length) -> string& {
|
||||
char* p = self.pointer();
|
||||
char* p = self.get();
|
||||
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();
|
||||
char* p = self.get();
|
||||
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]);
|
||||
@@ -67,13 +67,13 @@ auto size(string& self, signed length, char fill) -> string& {
|
||||
|
||||
if(size < length) { //expand
|
||||
self.resize(length);
|
||||
char* p = self.pointer();
|
||||
char* p = self.get();
|
||||
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();
|
||||
char* p = self.get();
|
||||
unsigned displacement = size - length;
|
||||
if(right) memory::move(p, p + displacement, length);
|
||||
self.resize(length);
|
||||
@@ -87,7 +87,7 @@ auto slice(const string& self, signed offset, signed length) -> string {
|
||||
if(offset < self.size()) {
|
||||
if(length < 0) length = self.size() - offset;
|
||||
result.resize(length);
|
||||
memory::copy(result.pointer(), self.data() + offset, length);
|
||||
memory::copy(result.get(), self.data() + offset, length);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ 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);
|
||||
memory::copy(result.get(), source.data() + offset, length);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user