...
 
Commits (9)
......@@ -81,7 +81,7 @@ static void OutputOctreeNode(hecl::blender::PyOutStream& os, athena::io::MemoryR
offsets[i] = r.readUint32Big();
u32 dataStart = r.position();
for (int i = 0; i < 8; ++i) {
r.seek(dataStart + offsets[i], athena::Begin);
r.seek(dataStart + offsets[i], athena::SeekOrigin::Begin);
int chFlags = (flags >> (i * 2)) & 0x3;
zeus::CAABox pos, neg, res;
......
#include "CCRC32.hpp"
#include "Runtime/CCRC32.hpp"
namespace urde {
#include <array>
const uint32_t CCRC32::crc32Table[256] = {
namespace urde {
namespace {
constexpr std::array<uint32_t, 256> crc32Table{
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832,
0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2,
0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A,
......@@ -31,14 +33,19 @@ const uint32_t CCRC32::crc32Table[256] = {
0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC,
0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330,
0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D};
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D,
};
constexpr uint32_t permute(uint32_t checksum, uint8_t b) { return (checksum >> 8) ^ crc32Table[(checksum & 0xFF) ^ b]; }
} // Anonymous namespace
uint32_t CCRC32::Calculate(const void* data, uint32_t length) {
if (!data || length == 0)
if (data == nullptr || length == 0) {
return 0;
}
uint32_t checksum = 0xFFFFFFFF;
const uint8_t* buf = reinterpret_cast<const uint8_t*>(data);
const uint8_t* buf = static_cast<const uint8_t*>(data);
uint32_t words = length / 4;
while ((words--) > 0) {
checksum = permute(checksum, *buf++);
......@@ -48,8 +55,9 @@ uint32_t CCRC32::Calculate(const void* data, uint32_t length) {
}
uint32_t rem = length % 4;
while ((rem--) > 0)
while ((rem--) > 0) {
checksum = permute(checksum, *buf++);
}
return checksum;
}
......
#pragma once
#include <cstdint>
namespace urde {
class CCRC32 {
static const uint32_t crc32Table[256];
static uint32_t permute(uint32_t checksum, uint8_t b) {
return (checksum >> 8) ^ crc32Table[(checksum & 0xFF) ^ b];
}
public:
static uint32_t Calculate(const void* data, uint32_t length);
};
......
This diff is collapsed.
#pragma once
#include "RetroTypes.hpp"
#include <string>
#include <unordered_map>
namespace urde {
class CAi;
class CStateManager;
enum class EStateMsg { Activate = 0, Update = 1, Deactivate = 2 };
class CStateManager;
class CAi;
typedef void (CAi::*CAiStateFunc)(CStateManager&, EStateMsg, float);
typedef bool (CAi::*CAiTriggerFunc)(CStateManager&, float);
using CAiStateFunc = void (CAi::*)(CStateManager&, EStateMsg, float);
using CAiTriggerFunc = bool (CAi::*)(CStateManager&, float);
class CAiFuncMap {
static const std::vector<std::string> gkStateNames;
std::unordered_map<std::string, CAiStateFunc> x0_stateFuncs;
std::unordered_map<std::string, CAiTriggerFunc> x10_triggerFuncs;
public:
CAiFuncMap();
CAiStateFunc GetStateFunc(const char*);
CAiTriggerFunc GetTriggerFunc(const char*);
CAiStateFunc GetStateFunc(const char*) const;
CAiTriggerFunc GetTriggerFunc(const char*) const;
};
} // namespace urde