mirror of
https://github.com/libretro/bsnes-libretro.git
synced 2024-11-23 17:09:44 +00:00
f9adb4d2c6
byuu says: The main thing I worked on today was emulating the MBC7 EEPROM. And... I have many things to say about that, but not here, and not now... The missing EEPROM support is why the accelerometer was broken. Although it's not evidently clear that I'm emulating the actual values incorrectly. I'll think about it and get it fixed, though. bsnes went from ~308fps to ~328fps, and I don't even know why. Probably something somewhere in the 140KB of changes to other things made in this WIP.
20 lines
629 B
C++
20 lines
629 B
C++
#pragma once
|
|
|
|
#include <nall/range.hpp>
|
|
|
|
namespace nall {
|
|
|
|
//counting sort by powers of two: used to implement radix sort
|
|
template<uint Bits, uint Shift, typename T>
|
|
auto counting_sort(T* output, const T* input, uint size) -> void {
|
|
static_assert(Bits >= 1 && Bits <= 20, "must be between 1 and 20 bits");
|
|
enum : uint { Base = 1 << Bits, Mask = Base - 1 };
|
|
|
|
uint64_t count[Base] = {}, last = 0;
|
|
for(uint n : range(size)) ++count[(input[n] >> Shift) & Mask];
|
|
for(uint n : range(Base)) last += count[n], count[n] = last - count[n];
|
|
for(uint n : range(size)) output[count[(input[n] >> Shift) & Mask]++] = input[n];
|
|
}
|
|
|
|
}
|