mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-04-02 10:42:14 -04:00
byuu says: Changelog: - fixed SNES sprite priority regression from r17 - added nall/windows/guard.hpp to guard against global namespace pollution (similar to nall/xorg/guard.hpp) - almost fixed Windows compilation (still accuracy profile only, sorry) - finished porting all of gba/ppu's registers over to the new .bit,.bits format ... all GBA registers.cpp files gone now - the "processors :=" line in the target-$(ui)/GNUmakefile is no longer required - processors += added to each emulator core - duplicates are removed using the new nall/GNUmakefile's $(unique) function - SFC core can be compiled without the GB core now - "-DSFC_SUPERGAMEBOY" is required to build in SGB support now (it's set in target-tomoko/GNUmakefile) - started once again on loki (higan/target-loki/) [as before, loki is Linux/BSD only on account of needing hiro::Console] loki shouldn't be too horrendous ... I hope. I just have the base skeleton ready for now. But the code from v094r08 should be mostly copyable over to it. It's just that it's about 50KiB of incredibly tricky code that has to be just perfect, so it's not going to be quick. But at least with the skeleton, it'll be a lot easier to pick away at it as I want. Windows compilation fix: move hiro/windows/header.hpp line 18 (header guard) to line 16 instead.
88 lines
1.8 KiB
C++
88 lines
1.8 KiB
C++
#pragma once
|
|
|
|
//UTF-8 <> UTF-16 conversion
|
|
//used only for Win32; every other OS uses UTF-8 internally
|
|
|
|
#if defined(_WIN32)
|
|
|
|
#undef UNICODE
|
|
#define UNICODE
|
|
#undef NOMINMAX
|
|
#define NOMINMAX
|
|
|
|
#include <nall/windows/guard.hpp>
|
|
#include <winsock2.h>
|
|
#include <windows.h>
|
|
#include <nall/windows/guard.hpp>
|
|
|
|
#if !defined(PATH_MAX)
|
|
#define PATH_MAX 260
|
|
#endif
|
|
|
|
using uint = unsigned;
|
|
|
|
namespace nall {
|
|
//UTF-8 to UTF-16
|
|
struct utf16_t {
|
|
utf16_t(const char* s = "") {
|
|
if(!s) s = "";
|
|
uint length = MultiByteToWideChar(CP_UTF8, 0, s, -1, nullptr, 0);
|
|
buffer = new wchar_t[length + 1]();
|
|
MultiByteToWideChar(CP_UTF8, 0, s, -1, buffer, length);
|
|
}
|
|
|
|
~utf16_t() {
|
|
delete[] buffer;
|
|
}
|
|
|
|
operator wchar_t*() {
|
|
return buffer;
|
|
}
|
|
|
|
operator const wchar_t*() const {
|
|
return buffer;
|
|
}
|
|
|
|
private:
|
|
wchar_t* buffer = nullptr;
|
|
};
|
|
|
|
//UTF-16 to UTF-8
|
|
struct utf8_t {
|
|
utf8_t(const wchar_t* s = L"") {
|
|
if(!s) s = L"";
|
|
uint length = WideCharToMultiByte(CP_UTF8, 0, s, -1, nullptr, 0, nullptr, nullptr);
|
|
buffer = new char[length + 1]();
|
|
WideCharToMultiByte(CP_UTF8, 0, s, -1, buffer, length, nullptr, nullptr);
|
|
}
|
|
|
|
~utf8_t() {
|
|
delete[] buffer;
|
|
}
|
|
|
|
utf8_t(const utf8_t&) = delete;
|
|
utf8_t& operator=(const utf8_t&) = delete;
|
|
|
|
operator char*() {
|
|
return buffer;
|
|
}
|
|
|
|
operator const char*() const {
|
|
return buffer;
|
|
}
|
|
|
|
private:
|
|
char* buffer = nullptr;
|
|
};
|
|
|
|
inline auto utf8_args(int& argc, char**& argv) -> void {
|
|
wchar_t** wargv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
|
argv = new char*[argc];
|
|
for(uint i = 0; i < argc; i++) {
|
|
argv[i] = new char[PATH_MAX];
|
|
strcpy(argv[i], nall::utf8_t(wargv[i]));
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif //if defined(_WIN32)
|