mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-24 07:02:27 +01:00
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.
107 lines
2.4 KiB
C++
107 lines
2.4 KiB
C++
#pragma once
|
|
|
|
//simple circular ring buffer
|
|
|
|
#include <nall/range.hpp>
|
|
#include <nall/serializer.hpp>
|
|
|
|
namespace nall {
|
|
|
|
template<typename T>
|
|
struct queue {
|
|
queue() = default;
|
|
queue(const queue& source) { operator=(source); }
|
|
queue(queue&& source) { operator=(move(source)); }
|
|
|
|
auto operator=(const queue& source) -> queue& {
|
|
if(this == &source) return *this;
|
|
reset();
|
|
_capacity = source._capacity;
|
|
_size = source._size;
|
|
_data = new T[_capacity];
|
|
for(uint n : range(_capacity)) _data[n] = source._data[n];
|
|
_read = source._read;
|
|
_write = source._write;
|
|
return *this;
|
|
}
|
|
|
|
auto operator=(queue&& source) -> queue& {
|
|
if(this == &source) return *this;
|
|
_data = source._data;
|
|
_capacity = source._capacity;
|
|
_size = source._size;
|
|
_read = source._read;
|
|
_write = source._write;
|
|
source._data = nullptr;
|
|
source.reset();
|
|
return *this;
|
|
}
|
|
|
|
~queue() {
|
|
reset();
|
|
}
|
|
|
|
template<typename U = T> auto capacity() const -> uint { return _capacity * sizeof(T) / sizeof(U); }
|
|
template<typename U = T> auto size() const -> uint { return _size * sizeof(T) / sizeof(U); }
|
|
auto empty() const -> bool { return _size == 0; }
|
|
auto pending() const -> bool { return _size > 0; }
|
|
auto full() const -> bool { return _size >= (int)_capacity; }
|
|
auto underflow() const -> bool { return _size < 0; }
|
|
auto overflow() const -> bool { return _size > (int)_capacity; }
|
|
|
|
auto data() -> T* { return _data; }
|
|
auto data() const -> const T* { return _data; }
|
|
|
|
auto reset() {
|
|
delete[] _data;
|
|
_data = nullptr;
|
|
_capacity = 0;
|
|
_size = 0;
|
|
_read = 0;
|
|
_write = 0;
|
|
}
|
|
|
|
auto resize(uint capacity, const T& value = {}) -> void {
|
|
reset();
|
|
_capacity = capacity;
|
|
_data = new T[_capacity];
|
|
for(uint n : range(_capacity)) _data[n] = value;
|
|
}
|
|
|
|
auto flush() -> void {
|
|
_size = 0;
|
|
_read = 0;
|
|
_write = 0;
|
|
}
|
|
|
|
auto read() -> T {
|
|
T value = _data[_read++];
|
|
if(_read >= _capacity) _read = 0;
|
|
_size--;
|
|
return value;
|
|
}
|
|
|
|
auto write(const T& value) -> void {
|
|
_data[_write++] = value;
|
|
if(_write >= _capacity) _write = 0;
|
|
_size++;
|
|
}
|
|
|
|
auto serialize(serializer& s) -> void {
|
|
s.array(_data, _capacity);
|
|
s.integer(_capacity);
|
|
s.integer(_size);
|
|
s.integer(_read);
|
|
s.integer(_write);
|
|
}
|
|
|
|
private:
|
|
T* _data = nullptr;
|
|
uint _capacity = 0;
|
|
int _size = 0;
|
|
uint _read = 0;
|
|
uint _write = 0;
|
|
};
|
|
|
|
}
|