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
|
|
|
image::image(const image& source) {
|
|
|
|
operator=(source);
|
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
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
image::image(image&& source) {
|
|
|
|
operator=(forward<image>(source));
|
|
|
|
}
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
image::image(bool endian, unsigned depth, uint64_t alphaMask, uint64_t redMask, uint64_t greenMask, uint64_t blueMask) {
|
|
|
|
_endian = endian;
|
|
|
|
_depth = depth;
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
_alpha = {alphaMask, bitDepth(alphaMask), bitShift(alphaMask)};
|
|
|
|
_red = {redMask, bitDepth(redMask), bitShift(redMask )};
|
|
|
|
_green = {greenMask, bitDepth(greenMask), bitShift(greenMask)};
|
|
|
|
_blue = {blueMask, bitDepth(blueMask), bitShift(blueMask )};
|
|
|
|
}
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
image::image(const string& filename) {
|
|
|
|
load(filename);
|
2014-01-13 09:35:46 +00:00
|
|
|
}
|
|
|
|
|
2018-08-05 09:00:15 +00:00
|
|
|
image::image(const void* data_, uint size) {
|
|
|
|
auto data = (const uint8_t*)data_;
|
|
|
|
if(size < 4);
|
2015-08-02 06:23:13 +00:00
|
|
|
else if(data[0] == 'B' && data[1] == 'M') loadBMP(data, size);
|
|
|
|
else if(data[1] == 'P' && data[2] == 'N' && data[3] == 'G') loadPNG(data, size);
|
2014-01-13 09:35:46 +00:00
|
|
|
}
|
|
|
|
|
2018-08-05 09:00:15 +00:00
|
|
|
image::image(const vector<uint8_t>& buffer) : image(buffer.data(), buffer.size()) {
|
|
|
|
}
|
|
|
|
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
template<uint Size> image::image(const uint8_t (&Name)[Size]) : image(Name, Size) {
|
2015-06-18 10:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
image::image() {
|
|
|
|
}
|
|
|
|
|
|
|
|
image::~image() {
|
|
|
|
free();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto image::operator=(const image& source) -> image& {
|
2015-06-12 13:14:38 +00:00
|
|
|
if(this == &source) return *this;
|
2014-01-13 09:35:46 +00:00
|
|
|
free();
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
_width = source._width;
|
|
|
|
_height = source._height;
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
_endian = source._endian;
|
|
|
|
_depth = source._depth;
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
_alpha = source._alpha;
|
|
|
|
_red = source._red;
|
|
|
|
_green = source._green;
|
|
|
|
_blue = source._blue;
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
_data = allocate(_width, _height, stride());
|
|
|
|
memory::copy(_data, source._data, source.size());
|
2014-01-13 09:35:46 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto image::operator=(image&& source) -> image& {
|
2015-06-12 13:14:38 +00:00
|
|
|
if(this == &source) return *this;
|
2014-01-13 09:35:46 +00:00
|
|
|
free();
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
_width = source._width;
|
|
|
|
_height = source._height;
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
_endian = source._endian;
|
|
|
|
_depth = source._depth;
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
_alpha = source._alpha;
|
|
|
|
_red = source._red;
|
|
|
|
_green = source._green;
|
|
|
|
_blue = source._blue;
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
_data = source._data;
|
|
|
|
source._data = nullptr;
|
2014-01-13 09:35:46 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
image::operator bool() const {
|
2016-05-16 09:51:12 +00:00
|
|
|
return _data && _width && _height;
|
2014-01-13 09:35:46 +00:00
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto image::operator==(const image& source) const -> bool {
|
|
|
|
if(_width != source._width) return false;
|
|
|
|
if(_height != source._height) return false;
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
if(_endian != source._endian) return false;
|
|
|
|
if(_depth != source._depth) return false;
|
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
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
if(_alpha != source._alpha) return false;
|
|
|
|
if(_red != source._red) return false;
|
|
|
|
if(_green != source._green) return false;
|
|
|
|
if(_blue != source._blue) return false;
|
2014-01-13 09:35:46 +00:00
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
return memory::compare(_data, source._data, size()) == 0;
|
2014-01-13 09:35:46 +00:00
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto image::operator!=(const image& source) const -> bool {
|
|
|
|
return !operator==(source);
|
2014-01-13 09:35:46 +00:00
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto image::read(const uint8_t* data) const -> uint64_t {
|
2014-01-13 09:35:46 +00:00
|
|
|
uint64_t result = 0;
|
2015-06-18 10:48:53 +00:00
|
|
|
if(_endian == 0) {
|
|
|
|
for(signed n = stride() - 1; n >= 0; n--) result = (result << 8) | data[n];
|
2014-01-13 09:35:46 +00:00
|
|
|
} else {
|
2015-06-18 10:48:53 +00:00
|
|
|
for(signed n = 0; n < stride(); n++) result = (result << 8) | data[n];
|
2014-01-13 09:35:46 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto image::write(uint8_t* data, uint64_t value) const -> void {
|
|
|
|
if(_endian == 0) {
|
|
|
|
for(signed n = 0; n < stride(); n++) {
|
2014-01-13 09:35:46 +00:00
|
|
|
data[n] = value;
|
|
|
|
value >>= 8;
|
|
|
|
}
|
|
|
|
} else {
|
2015-06-18 10:48:53 +00:00
|
|
|
for(signed n = stride() - 1; n >= 0; n--) {
|
2014-01-13 09:35:46 +00:00
|
|
|
data[n] = value;
|
|
|
|
value >>= 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto image::free() -> void {
|
|
|
|
if(_data) delete[] _data;
|
|
|
|
_data = nullptr;
|
2014-01-13 09:35:46 +00:00
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto image::load(const string& filename) -> bool {
|
2014-01-13 09:35:46 +00:00
|
|
|
if(loadBMP(filename) == true) return true;
|
|
|
|
if(loadPNG(filename) == true) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-08-06 07:46:00 +00:00
|
|
|
//assumes image and data are in the same format; pitch is adapted to image
|
|
|
|
auto image::copy(const void* data, uint pitch, uint width, uint height) -> void {
|
|
|
|
allocate(width, height);
|
|
|
|
for(uint y : range(height)) {
|
|
|
|
auto input = (const uint8_t*)data + y * pitch;
|
|
|
|
auto output = (uint8_t*)_data + y * this->pitch();
|
|
|
|
memory::copy(output, input, width * stride());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-18 10:48:53 +00:00
|
|
|
auto image::allocate(unsigned width, unsigned height) -> void {
|
|
|
|
if(_data && _width == width && _height == height) return;
|
2014-01-13 09:35:46 +00:00
|
|
|
free();
|
2015-06-18 10:48:53 +00:00
|
|
|
_width = width;
|
|
|
|
_height = height;
|
|
|
|
_data = allocate(_width, _height, stride());
|
2014-01-13 09:35:46 +00:00
|
|
|
}
|
|
|
|
|
2018-08-06 07:46:00 +00:00
|
|
|
//private
|
2015-06-18 10:48:53 +00:00
|
|
|
auto image::allocate(unsigned width, unsigned height, unsigned stride) -> uint8_t* {
|
2014-01-13 09:35:46 +00:00
|
|
|
//allocate 1x1 larger than requested; so that linear interpolation does not require bounds-checking
|
|
|
|
unsigned size = width * height * stride;
|
|
|
|
unsigned padding = width * stride + stride;
|
2015-06-18 10:48:53 +00:00
|
|
|
auto data = new uint8_t[size + padding];
|
|
|
|
memory::fill(data + size, padding);
|
2014-01-13 09:35:46 +00:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|