diff options
author | german77 <juangerman-13@hotmail.com> | 2023-09-17 18:47:39 +0200 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2023-09-18 00:06:25 +0200 |
commit | a50b50f8b4450331fa44f18b7457affa001ab6c9 (patch) | |
tree | 9aa80d98fdc6d742231b4c052d01d8f1da88d540 /src/core/hle/service/mii/mii_database.h | |
parent | service: mii: Add device crc16 (diff) | |
download | yuzu-a50b50f8b4450331fa44f18b7457affa001ab6c9.tar yuzu-a50b50f8b4450331fa44f18b7457affa001ab6c9.tar.gz yuzu-a50b50f8b4450331fa44f18b7457affa001ab6c9.tar.bz2 yuzu-a50b50f8b4450331fa44f18b7457affa001ab6c9.tar.lz yuzu-a50b50f8b4450331fa44f18b7457affa001ab6c9.tar.xz yuzu-a50b50f8b4450331fa44f18b7457affa001ab6c9.tar.zst yuzu-a50b50f8b4450331fa44f18b7457affa001ab6c9.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/mii/mii_database.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/core/hle/service/mii/mii_database.h b/src/core/hle/service/mii/mii_database.h new file mode 100644 index 000000000..01764999f --- /dev/null +++ b/src/core/hle/service/mii/mii_database.h @@ -0,0 +1,66 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "core/hle/result.h" +#include "core/hle/service/mii/types/store_data.h" + +namespace Service::Mii { + +constexpr std::size_t MaxDatabaseLength{100}; +constexpr u32 MiiMagic{0xa523b78f}; +constexpr u32 DatabaseMagic{0x4244464e}; // NFDB + +class NintendoFigurineDatabase { +public: + /// Returns the total mii count. + u8 GetDatabaseLength() const; + + /// Returns full if database is full. + bool IsFull() const; + + /// Returns the mii of the specified index. + StoreData Get(std::size_t index) const; + + /// Returns the total mii count. Ignoring special mii. + u32 GetCount(const DatabaseSessionMetadata& metadata) const; + + /// Returns the index of a mii. If the mii isn't found returns false. + bool GetIndexByCreatorId(u32& out_index, const Common::UUID& create_id) const; + + /// Moves the location of a specific mii. + Result Move(u32 current_index, u32 new_index); + + /// Replaces mii with new data. + void Replace(u32 index, const StoreData& store_data); + + /// Adds a new mii to the end of the database. + void Add(const StoreData& store_data); + + /// Removes mii from database and shifts left the remainding data. + void Delete(u32 index); + + /// Deletes all contents with a fresh database + void CleanDatabase(); + + /// Intentionally sets a bad checksum + void CorruptCrc(); + + /// Returns success if database is valid otherwise returns the corresponding error code. + Result CheckIntegrity(); + +private: + /// Returns the checksum of the database + u16 GenerateDatabaseCrc(); + + u32 magic{}; // 'NFDB' + std::array<StoreData, MaxDatabaseLength> miis{}; + u8 version{}; + u8 database_length{}; + u16 crc{}; +}; +static_assert(sizeof(NintendoFigurineDatabase) == 0x1A98, + "NintendoFigurineDatabase has incorrect size."); + +}; // namespace Service::Mii |