2016-01-07 08:14:33 +00:00
|
|
|
#pragma once
|
2014-01-13 09:35:46 +00:00
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto image::loadBMP(const string& filename) -> bool {
|
2015-08-02 06:23:13 +00:00
|
|
|
if(!file::exists(filename)) return false;
|
|
|
|
auto buffer = file::read(filename);
|
|
|
|
return loadBMP(buffer.data(), buffer.size());
|
|
|
|
}
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-08-02 06:23:13 +00:00
|
|
|
auto image::loadBMP(const uint8_t* bmpData, unsigned bmpSize) -> bool {
|
|
|
|
Decode::BMP source;
|
|
|
|
if(!source.load(bmpData, bmpSize)) return false;
|
|
|
|
|
|
|
|
allocate(source.width(), source.height());
|
|
|
|
const uint32_t* sp = source.data();
|
2015-06-18 10:48:53 +00:00
|
|
|
uint8_t* dp = _data;
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-08-02 06:23:13 +00:00
|
|
|
for(unsigned y = 0; y < _height; y++) {
|
|
|
|
for(unsigned x = 0; x < _width; x++) {
|
2014-01-13 09:35:46 +00:00
|
|
|
uint32_t color = *sp++;
|
2015-06-18 10:48:53 +00:00
|
|
|
uint64_t a = normalize((uint8_t)(color >> 24), 8, _alpha.depth());
|
|
|
|
uint64_t r = normalize((uint8_t)(color >> 16), 8, _red.depth());
|
|
|
|
uint64_t g = normalize((uint8_t)(color >> 8), 8, _green.depth());
|
|
|
|
uint64_t b = normalize((uint8_t)(color >> 0), 8, _blue.depth());
|
|
|
|
write(dp, (a << _alpha.shift()) | (r << _red.shift()) | (g << _green.shift()) | (b << _blue.shift()));
|
|
|
|
dp += stride();
|
2014-01-13 09:35:46 +00:00
|
|
|
}
|
|
|
|
}
|
Update to v103r23 release.
byuu says:
Changelog:
- gb: added accelerometer X-axis, Y-Axis inputs¹
- gb: added rumble input¹
- gb/mbc5: added rumble support²
- gb/mbc6: added skeleton driver, but it doesn't boot Net de Get
- gb/mbc7: added mostly complete driver (only missing EEPROM), but it
doesn't boot Kirby Tilt 'n' Tumble
- gb/tama: added leap year assignment
- tomoko: fixed macOS compilation [MerryMage]
- hiro/cocoa: fix table cell redrawing on updates and automatic column
resizing [ncbncb]
- hiro/cocoa: fix some weird issue with clicking table view checkboxes
on Retina displays [ncbncb]
- icarus: enhance Game Boy heuristics³
- nall: fix three missing return statements [Jonas Quinn]
- ruby: hopefully fixed all compilation errors reported by Screwtape
et al⁴
¹: because there's no concept of a controller for cartridge inputs,
I'm attaching to the base platform for now. An idea I had was to make
separate ports for each cartridge type ... but this would duplicate the
rumble input between MBC5 and MBC7. And would also be less discoverable.
But it would be more clean in that users wouldn't think the Game Boy
hardware had this functionality. I'll think about it.
²: it probably won't work yet. Rumble isn't documented anywhere, but
I dug through an emulator named GEST and discovered that it seems to use
bit 3 of the RAM bank select to be rumble. I don't know if it sets the
bit for rumbling, then clears when finished, or if it sets it and then
after a few milliseconds it stops rumbling. I couldn't test on my
FreeBSD box because SDL 1.2 doesn't support rumble, udev doesn't exist
on FreeBSD, and nobody has ever posted any working code for how to use
evdev (or whatever it's called) on FreeBSD.
³: I'm still thinking about specifying the MBC7 RAM as EEPROM, since
it's not really static RAM.
⁴: if possible, please test all drivers if you can. I want to ensure
they're all working. Especially let me know if the following work:
macOS: input.carbon Linux: audio.pulseaudiosimple, audio.ao (libao)
If I can confirm these are working, I'm going to then remove them from
being included with stock higan builds.
I'm also considering dropping SDL video on Linux/BSD. XShm is much
faster and supports blurring. I may also drop SDL input on Linux, since
udev works better. That will free a dependency on SDL 1.2 for building
higan. FreeBSD is still going to need it for joypad support, however.
2017-07-30 13:00:31 +00:00
|
|
|
|
|
|
|
return true;
|
2014-01-13 09:35:46 +00:00
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto image::loadPNG(const string& filename) -> bool {
|
2014-01-13 09:35:46 +00:00
|
|
|
if(!file::exists(filename)) return false;
|
|
|
|
auto buffer = file::read(filename);
|
|
|
|
return loadPNG(buffer.data(), buffer.size());
|
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto image::loadPNG(const uint8_t* pngData, unsigned pngSize) -> bool {
|
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.
2015-02-26 10:10:46 +00:00
|
|
|
Decode::PNG source;
|
2015-08-02 06:23:13 +00:00
|
|
|
if(!source.load(pngData, pngSize)) return false;
|
2014-01-13 09:35:46 +00:00
|
|
|
|
|
|
|
allocate(source.info.width, source.info.height);
|
|
|
|
const uint8_t* sp = source.data;
|
2015-06-18 10:48:53 +00:00
|
|
|
uint8_t* dp = _data;
|
2014-01-13 09:35:46 +00:00
|
|
|
|
|
|
|
auto decode = [&]() -> uint64_t {
|
|
|
|
uint64_t p, r, g, b, a;
|
|
|
|
|
|
|
|
switch(source.info.colorType) {
|
|
|
|
case 0: //L
|
|
|
|
r = g = b = source.readbits(sp);
|
|
|
|
a = (1 << source.info.bitDepth) - 1;
|
|
|
|
break;
|
|
|
|
case 2: //R,G,B
|
|
|
|
r = source.readbits(sp);
|
|
|
|
g = source.readbits(sp);
|
|
|
|
b = source.readbits(sp);
|
|
|
|
a = (1 << source.info.bitDepth) - 1;
|
|
|
|
break;
|
|
|
|
case 3: //P
|
|
|
|
p = source.readbits(sp);
|
|
|
|
r = source.info.palette[p][0];
|
|
|
|
g = source.info.palette[p][1];
|
|
|
|
b = source.info.palette[p][2];
|
|
|
|
a = (1 << source.info.bitDepth) - 1;
|
|
|
|
break;
|
|
|
|
case 4: //L,A
|
|
|
|
r = g = b = source.readbits(sp);
|
|
|
|
a = source.readbits(sp);
|
|
|
|
break;
|
|
|
|
case 6: //R,G,B,A
|
|
|
|
r = source.readbits(sp);
|
|
|
|
g = source.readbits(sp);
|
|
|
|
b = source.readbits(sp);
|
|
|
|
a = source.readbits(sp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
a = normalize(a, source.info.bitDepth, _alpha.depth());
|
|
|
|
r = normalize(r, source.info.bitDepth, _red.depth());
|
|
|
|
g = normalize(g, source.info.bitDepth, _green.depth());
|
|
|
|
b = normalize(b, source.info.bitDepth, _blue.depth());
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
return (a << _alpha.shift()) | (r << _red.shift()) | (g << _green.shift()) | (b << _blue.shift());
|
2014-01-13 09:35:46 +00:00
|
|
|
};
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
for(unsigned y = 0; y < _height; y++) {
|
|
|
|
for(unsigned x = 0; x < _width; x++) {
|
2014-01-13 09:35:46 +00:00
|
|
|
write(dp, decode());
|
2015-06-18 10:48:53 +00:00
|
|
|
dp += stride();
|
2014-01-13 09:35:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|