Files
aurora/lib/card/BlockAllocationTable.hpp
CraftyBoss a801671643 Card gci folder update (#135)
* add ability to set path of card image before CARDInit

* begin work on updating card class to support gci folders

a lot of work will just be directly reading from whatever folder is supplied, instead of relying on an always open FileIO handle

* swap to interface system for easier code seperation, begin actually planning out logic for gci loading

* fix wrong name for func, add modified time to new gci file entry

* get gci folder working

tp seems to be happy with everything ive done, the only funcs im worried about are getSerial and getChecksum as those dont do anything atm.

* fix createFile not assigning file index to output FileHandle, CARDSetLoadType now takes an enum

* make probeCardFile a virtual func so GciFolder and RawFile can both implement their own, bit of cleanup
2026-04-23 22:39:42 -07:00

40 lines
1021 B
C++

#pragma once
#include <array>
#include <cstdint>
#include "Constants.hpp"
namespace aurora::card {
class BlockAllocationTable {
friend class CardRawFile;
#pragma pack(push, 4)
union {
struct {
uint16_t m_checksum;
uint16_t m_checksumInv;
uint16_t m_updateCounter;
uint16_t m_freeBlocks;
uint16_t m_lastAllocated;
std::array<uint16_t, 0xFFB> m_map;
};
std::array<uint8_t, BlockSize> raw{};
};
#pragma pack(pop)
void swapEndian();
void updateChecksum();
bool valid() const;
public:
explicit BlockAllocationTable(uint32_t blockCount = (static_cast<uint32_t>(ECardSize::Card2043Mb) * MbitToBlocks));
~BlockAllocationTable() = default;
uint16_t getNextBlock(uint16_t block) const;
uint16_t nextFreeBlock(uint16_t maxBlock, uint16_t startingBlock) const;
bool clear(uint16_t first, uint16_t count);
uint16_t allocateBlocks(uint16_t count, uint16_t maxBlocks);
uint16_t numFreeBlocks() const { return m_freeBlocks; }
};
} // namespace aurora::card