bsnes-libretro/nall/iterator.hpp
Tim Allen 4d7bb510f2 Update to bsnes v107.1 release.
byuu says:

Don't let the point release fool you, there are many significant changes in this
release. I will be keeping bsnes releases using a point system until the new
higan release is ready.

Changelog:

  - GUI: added high DPI support
  - GUI: fixed the state manager image preview
  - Windows: added a new waveOut driver with support for dynamic rate control
  - Windows: corrected the XAudio 2.1 dynamic rate control support [BearOso]
  - Windows: corrected the Direct3D 9.0 fullscreen exclusive window centering
  - Windows: fixed XInput controller support on Windows 10
  - SFC: added high-level emulation for the DSP1, DSP2, DSP4, ST010, and Cx4
    coprocessors
  - SFC: fixed a slight rendering glitch in the intro to Megalomania

If the coprocessor firmware is missing, bsnes will fallback on HLE where it is
supported, which is everything other than SD Gundam GX and the two Hayazashi
Nidan Morita Shougi games.

The Windows dynamic rate control works best with Direct3D in fullscreen
exclusive mode. I recommend the waveOut driver over the XAudio 2.1 driver, as it
is not possible to target a single XAudio2 version on all Windows OS releases.
The waveOut driver should work everywhere out of the box.

Note that with DRC, the synchronization source is your monitor, so you will
want to be running at 60hz (NTSC) or 50hz (PAL). If you have an adaptive sync
monitor, you should instead use the WASAPI (exclusive) or ASIO audio driver.
2019-04-09 11:16:30 +10:00

80 lines
2.6 KiB
C++

#pragma once
namespace nall {
template<typename T> struct iterator {
iterator(T* self, uint64_t offset) : _self(self), _offset(offset) {}
auto operator*() -> T& { return _self[_offset]; }
auto operator!=(const iterator& source) const -> bool { return _offset != source._offset; }
auto operator++() -> iterator& { return _offset++, *this; }
auto offset() const -> uint64_t { return _offset; }
private:
T* _self;
uint64_t _offset;
};
template<typename T> struct iterator_const {
iterator_const(const T* self, uint64_t offset) : _self(self), _offset(offset) {}
auto operator*() -> const T& { return _self[_offset]; }
auto operator!=(const iterator_const& source) const -> bool { return _offset != source._offset; }
auto operator++() -> iterator_const& { return _offset++, *this; }
auto offset() const -> uint64_t { return _offset; }
private:
const T* _self;
uint64_t _offset;
};
template<typename T> struct reverse_iterator {
reverse_iterator(T* self, uint64_t offset) : _self(self), _offset(offset) {}
auto operator*() -> T& { return _self[_offset]; }
auto operator!=(const reverse_iterator& source) const -> bool { return _offset != source._offset; }
auto operator++() -> reverse_iterator& { return _offset--, *this; }
auto offset() const -> uint64_t { return _offset; }
private:
T* _self;
uint64_t _offset;
};
template<typename T> struct reverse_iterator_const {
reverse_iterator_const(const T* self, uint64_t offset) : _self(self), _offset(offset) {}
auto operator*() -> const T& { return _self[_offset]; }
auto operator!=(const reverse_iterator_const& source) const -> bool { return _offset != source._offset; }
auto operator++() -> reverse_iterator_const& { return _offset--, *this; }
auto offset() const -> uint64_t { return _offset; }
private:
const T* _self;
uint64_t _offset;
};
//std::rbegin(), std::rend() is missing from GCC 4.9; which I still target
template<typename T, uint64_t Size> auto rbegin(T (&array)[Size]) { return reverse_iterator<T>{array, Size - 1}; }
template<typename T, uint64_t Size> auto rend(T (&array)[Size]) { return reverse_iterator<T>{array, (uint64_t)-1}; }
template<typename T> auto rbegin(T& self) { return self.rbegin(); }
template<typename T> auto rend(T& self) { return self.rend(); }
template<typename T> struct reverse_wrapper {
auto begin() { return rbegin(_self); }
auto end() { return rend(_self); }
auto begin() const { return rbegin(_self); }
auto end() const { return rend(_self); }
T _self;
};
template<typename T> auto reverse(T& object) -> reverse_wrapper<T&> {
return {object};
}
template<typename T> auto reverse(T&& object) -> reverse_wrapper<T> {
return {object};
}
}