A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
CRC32.hh
1#pragma once
2
3#include "Common.hh"
4
5namespace Abstract {
6
8[[nodiscard]] constexpr u32 CalcCRC32(u8 *data, u32 size) {
10 constexpr u32 LOOKUP_TABLE[16] = {
11 0x00000000,
12 0x1DB71064,
13 0x3B6E20C8,
14 0x26D930AC,
15 0x76DC4190,
16 0x6B6B51F4,
17 0x4DB26158,
18 0x5005713C,
19 0xEDB88320,
20 0xF00F9344,
21 0xD6D6A3E8,
22 0xCB61B38C,
23 0x9B64C2B0,
24 0x86D3D2D4,
25 0xA00AE278,
26 0xBDBDF21C,
27 };
28
29 u32 ret = std::numeric_limits<u32>::max();
30
31 for (u32 i = 0; i < size; ++i) {
32 ret = (ret >> 4) ^ LOOKUP_TABLE[(ret ^ data[i]) & 0xF];
33 ret = (ret >> 4) ^ LOOKUP_TABLE[(ret ^ (data[i] >> 4)) & 0xF];
34 }
35
36 return ~ret;
37}
38
39} // namespace Abstract
This header houses common data types such as our integral types and enums.
An abstraction of components from the nw4r and RVL libraries.
Definition Archive.cc:5
constexpr u32 CalcCRC32(u8 *data, u32 size)
Definition CRC32.hh:8