mirror of https://github.com/bsnes-emu/bsnes.git
Update to bsnes v039r22? release.
New WIP. Softened the panel titles a lot, they take less space but still stand out well enough. Should I add a checkbox+global hotkey to toggle the cheat code system itself on and off? Ala the flip switch that's on the real Game Genie. Not sure if it's as important anymore now that it's easy to group multiple cheat codes together and toggle them with just one checkbox. If so, I need a caption for the checkbox widget, eg "Enable cheat code system", but something more descriptive. Rewrote a couple chunks of the nall::string library. I had a lot of problems with casting due to things like this: int strdec(const char*); string strdec(int); string::operator int(); string::operator const char*(); string::operator=(int); string::operator=(const char*); string::operator<<(int); string::operator<<(const char*); string::string(int); string::string(const char*); It couldn't implicitly determine if string() << 0 should refer 0 as const char* or int. So I started by dropping the string->integer implicit conversions, no need for those, use the strTransform(string) functions instead. More verbose of the format you want anyway (eg signed or unsigned integer). Next, rather than try and implement signed+unsigned+signed short+unsigned short+signed char etc etc for string::operator= + string::operator<<, I instead wrote them to use templates. Worked around the limitation that classes can't use explicit template specialization by using global thunk functions. operator<<, operator= and lstring::operator<< all share one set of template specialization functions to perform conversion of any supported type to a string for assignment or appending. Pass an unsupported type and it will throw a "template function undefined" error and fail to compile. No run-time surprises. I was careful to implement the copy constructor and copy operator= to stop the compiler from generating its own functions that copy around the raw pointer (which would lead to memory leaks + double memory frees.) So it should be 100% leak proof. I also split strdec(int) into strsigned(signed) and strunsigned(unsigned); and updated all the other stuff that used the lib for that (eg nall::config et al), so you can now perform unsigned->string conversions on UINT_MAX without getting back -1. Only thing I'm debating now is if I want to trade C compatibility for speed and store the string lengths inside the string class for O(1) length + append functions, compared to their O(n) now. Multiple chained appends raise that to O(n^2), but with ~20 appends at most per string, it's hardly a bottleneck right now. I'm hesitant to do this, because if I do, I'll have to remove char* operator()() to give a raw handle to the string pointer. I use that for quick libc const char*->string& wrapper functions, and it's also nice for other functions to use. And char& operator[](size_t) would take a hell of a speed hit for having to check for '\0' writes to adjust the length internally. _Not_ going to allow storing '\0' directly ala std::string, and make string::c_str() require memory allocation. Fuck that. Use an appropriate binary container if you want '\0' inside a block of memory. The whole idea of nall::string is to maintain 100% compatibility with C89 strings and their functions. [No archive available]
This commit is contained in:
parent
45feae8f75
commit
3e7578761a