namco/ns10crypt.cpp: Use native population count helper in place of table.

This commit is contained in:
Vas Crabb 2023-04-20 01:06:18 +10:00
parent f0dae0ef09
commit b35ba6b31d
2 changed files with 1 additions and 26 deletions

View file

@ -261,23 +261,3 @@ void ns10_type2_decrypter_device::device_start()
m_active = false;
}
// create a lookup table of GF2 reductions of 16-bits words
static constexpr int make_gf2_reduction(uint32_t i)
{
i ^= i >> 8;
i ^= i >> 4;
i ^= i >> 2;
i ^= i >> 1;
return int(i & 1);
}
template <uint32_t... Values>
static constexpr auto make_gf2_reduction(std::integer_sequence<uint32_t, Values...>)
{
return std::array<int, sizeof...(Values)>({ make_gf2_reduction(Values)... });
}
const std::array<int, 0x1'0000> ns10_type2_decrypter_device::GF2_REDUCTION = make_gf2_reduction(std::make_integer_sequence<uint32_t, 0x1'0000>());

View file

@ -72,11 +72,7 @@ public:
static int gf2_reduce(uint64_t num)
{
return
GF2_REDUCTION[num & 0xffff] ^
GF2_REDUCTION[(num >> 16) & 0xffff] ^
GF2_REDUCTION[(num >> 32) & 0xffff] ^
GF2_REDUCTION[num >> 48];
return population_count_64(num) & 1;
}
protected:
@ -84,7 +80,6 @@ protected:
private:
static const int INIT_SBOX[16];
static const std::array<int, 0x1'0000> GF2_REDUCTION;
virtual void init(int iv) override;