Kinoko
A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
Archive.hh
1
#pragma once
2
3
#include <
Common.hh
>
4
5
// TODO: for the love of god please find a better name this is not called a "U8" archive
6
#define U8_SIGNATURE 0x55AA382D
7
9
namespace
Abstract
{
10
11
class
ArchiveHandle
{
12
public
:
13
struct
RawArchive
{
14
[[nodiscard]]
bool
isValidSignature()
const
{
15
return
parse<u32>(signature) == U8_SIGNATURE;
16
}
17
18
u32
signature;
19
u32
nodesOffset;
20
u32
nodesSize;
21
u32
filesOffset;
22
};
23
24
// TODO: union
25
struct
Node
{
26
[[nodiscard]]
bool
isDirectory()
const
{
27
return
!!(str[0]);
28
}
29
30
[[nodiscard]]
u32
stringOffset()
const
{
31
return
parse<u32>(val) & 0xFFFFFF;
32
}
33
34
union
{
35
u32
val;
36
u8 str[4];
37
};
38
union
{
39
struct
{
40
u32
parent;
41
u32
next;
42
} m_directory;
43
struct
{
44
u32
startAddress;
45
u32
length;
46
} file;
47
};
48
};
49
50
struct
FileInfo
{
51
u32
startOffset;
52
u32
length;
53
};
54
55
ArchiveHandle
(
void
*archiveStart);
56
57
[[nodiscard]]
s32
convertPathToEntryId(
const
char
*path)
const
;
58
bool
open(
s32
entryId,
FileInfo
&info)
const
;
59
61
[[nodiscard]]
void
*getFileAddress(
const
FileInfo
&info)
const
{
62
return
static_cast<
u8 *
>
(m_startAddress) + info.startOffset;
63
}
64
65
[[nodiscard]] Node *node(s32 entryId)
const
{
66
auto
*nodeAddress =
static_cast<
u8 *
>
(m_nodesAddress) +
sizeof
(Node) * entryId;
67
return
reinterpret_cast<
Node *
>
(nodeAddress);
68
}
69
70
[[nodiscard]]
void
*startAddress()
const
{
71
return
m_startAddress;
72
}
73
74
private
:
75
void
*m_startAddress;
76
void
*m_nodesAddress;
77
void
*m_filesAddress;
78
u32
m_count;
79
u32
m_currentNode;
80
const
char
*m_strings;
81
};
82
83
}
// namespace Abstract
Common.hh
This header houses common data types such as our integral types and enums.
Abstract::ArchiveHandle
Definition
Archive.hh:11
int32_t
uint32_t
Abstract
An abstraction of components from the nw4r and RVL libraries.
Definition
Archive.cc:5
Abstract::ArchiveHandle::FileInfo
Definition
Archive.hh:50
Abstract::ArchiveHandle::Node
Definition
Archive.hh:25
Abstract::ArchiveHandle::RawArchive
Definition
Archive.hh:13
abstract
Archive.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.12.0