mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-13 04:05:01 +02:00
Update to v094r43 release.
byuu says: Updated to compile with all of the new hiro changes. My next step is to write up hiro API documentation, and move the API from alpha (constantly changing) to beta (rarely changing), in preparation for the first stable release (backward-compatible changes only.) Added "--fullscreen" command-line option. I like this over a configuration file option. Lets you use the emulator in both modes without having to modify the config file each time. Also enhanced the command-line game loading. You can now use any of these methods: higan /path/to/game-folder.sfc higan /path/to/game-folder.sfc/ higan /path/to/game-folder.sfc/program.rom The idea is to support launchers that insist on loading files only. Technically, the file can be any name (manifest.bml also works); the only criteria is that the file actually exists and is a file, and not a directory. This is a requirement to support the first version (a directory lacking the trailing / identifier), because I don't want my nall::string class to query the file system to determine if the string is an actual existing file or directory for its pathname() / dirname() functions. Anyway, every game folder I've made so far has program.rom, and that's very unlikely to change, so this should be fine. Now, of course, if you drop a regular "game.sfc" file on the emulator, it won't even try to load it, unless it's in a folder that ends in .fc, .sfc, etc. In which case, it'll bail out immediately by being unable to produce a manifest for what is obviously not really a game folder.
This commit is contained in:
@@ -5,6 +5,8 @@ static const unsigned WindowsXP = 0x0501;
|
||||
static const unsigned WindowsVista = 0x0600;
|
||||
static const unsigned Windows7 = 0x0601;
|
||||
|
||||
static auto Button_CustomDraw(HWND, PAINTSTRUCT&, unsigned, const Font&, const Image&, Orientation, const string&) -> void;
|
||||
|
||||
static auto OsVersion() -> unsigned {
|
||||
OSVERSIONINFO versionInfo{0};
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
@@ -12,7 +14,9 @@ static auto OsVersion() -> unsigned {
|
||||
return (versionInfo.dwMajorVersion << 8) + (versionInfo.dwMajorVersion << 0);
|
||||
}
|
||||
|
||||
static auto CreateBitmap(const image& icon) -> HBITMAP {
|
||||
static auto CreateBitmap(image icon) -> HBITMAP {
|
||||
icon.alphaMultiply(); //Windows AlphaBlend() requires premultiplied image data
|
||||
icon.transform();
|
||||
HDC hdc = GetDC(0);
|
||||
BITMAPINFO bitmapInfo;
|
||||
memset(&bitmapInfo, 0, sizeof(BITMAPINFO));
|
||||
@@ -30,6 +34,33 @@ static auto CreateBitmap(const image& icon) -> HBITMAP {
|
||||
return hbitmap;
|
||||
}
|
||||
|
||||
static auto CreateBitmap(const Image& image) -> HBITMAP {
|
||||
HDC hdc = GetDC(0);
|
||||
BITMAPINFO bitmapInfo{0};
|
||||
bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bitmapInfo.bmiHeader.biWidth = image.width();
|
||||
bitmapInfo.bmiHeader.biHeight = -image.height(); //bitmaps are stored upside down unless we negate height
|
||||
bitmapInfo.bmiHeader.biPlanes = 1;
|
||||
bitmapInfo.bmiHeader.biBitCount = 32;
|
||||
bitmapInfo.bmiHeader.biCompression = BI_RGB;
|
||||
bitmapInfo.bmiHeader.biSizeImage = image.width() * image.height() * sizeof(uint32_t);
|
||||
void* bits = nullptr;
|
||||
HBITMAP hbitmap = CreateDIBSection(hdc, &bitmapInfo, DIB_RGB_COLORS, &bits, nullptr, 0);
|
||||
if(bits) {
|
||||
auto source = (const uint8_t*)image.data();
|
||||
auto target = (uint8_t*)bits;
|
||||
for(auto n : range(image.width() * image.height())) {
|
||||
target[0] = (source[0] * source[3]) / 255;
|
||||
target[1] = (source[1] * source[3]) / 255;
|
||||
target[2] = (source[2] * source[3]) / 255;
|
||||
target[3] = (source[3]);
|
||||
source += 4, target += 4;
|
||||
}
|
||||
}
|
||||
ReleaseDC(0, hdc);
|
||||
return hbitmap;
|
||||
}
|
||||
|
||||
static auto CreateRGB(const Color& color) -> COLORREF {
|
||||
return RGB(color.red(), color.green(), color.blue());
|
||||
}
|
||||
@@ -62,16 +93,18 @@ static auto GetWindowZOrder(HWND hwnd) -> unsigned {
|
||||
return z;
|
||||
}
|
||||
|
||||
static auto ImageList_Append(HIMAGELIST imageList, const image& source, unsigned scale) -> void {
|
||||
auto image = source;
|
||||
if(image.empty()) {
|
||||
image.allocate(scale, scale);
|
||||
image.fill(GetSysColor(COLOR_WINDOW));
|
||||
static auto ImageList_Append(HIMAGELIST imageList, const Image& image, unsigned scale) -> void {
|
||||
nall::image icon;
|
||||
if(image) {
|
||||
icon.allocate(image.width(), image.height());
|
||||
memory::copy(icon.data(), image.data(), icon.size());
|
||||
icon.scale(scale, scale);
|
||||
} else {
|
||||
icon.allocate(scale, scale);
|
||||
icon.fill(GetSysColor(COLOR_WINDOW));
|
||||
}
|
||||
image.transform();
|
||||
image.scale(scale, scale);
|
||||
HBITMAP bitmap = CreateBitmap(image);
|
||||
ImageList_Add(imageList, bitmap, NULL);
|
||||
HBITMAP bitmap = CreateBitmap(icon);
|
||||
ImageList_Add(imageList, bitmap, nullptr);
|
||||
DeleteObject(bitmap);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user