summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorcristian64 <cristian64@gmail.com>2026-03-27 11:30:52 +0000
committercristian64 <cristian64@gmail.com>2026-07-11 23:02:54 +0100
commit24ad5628717df1184fcbac027cd27618891afc40 (patch)
tree1850c0898a36bb4376204701665426bd3418f223 /Source/Core
parent6de526c684ee6dd8b6fc3447dae858ae480ccbb5 (diff)
Core: Add `Volume::GetSimulatedMemorySize()`.
The data structure of the `bi2.bin` file in which the simulated memory size is set: > **13.2 Disk header Information** > > this is loaded to the Address in `0x800000f4` when a disc is initialized by the IPL > > | offset | end | size | Description | > | :------: | --- | :--: | --------------------- | > | `0x0000` | | 4 | Debug-monitor Size | > | `0x0004` | | 4 | Simulated Memory Size | > | `0x0008` | | 4 | Argument offset | > | `0x000c` | | 4 | Debug flag | > | `0x0010` | | 4 | Track Location | > | `0x0014` | | 4 | Track size | > | `0x0018` | | 4 | Countrycode | > | `0x001c` | | 4 | ? | See https://hitmen.c02.at/files/yagcd/yagcd/chap13.html#sec13.2. Most GameCube games set the value to `24 MiB`, which matches the physical memory size. Most Wii games set the value to `0 MiB` (unset). The debug build of _Mario Kart: Double Dash!!_ is one game that sets the value to `48 MiB`.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DiscIO/Volume.h1
-rw-r--r--Source/Core/DiscIO/VolumeDisc.cpp8
-rw-r--r--Source/Core/DiscIO/VolumeDisc.h1
-rw-r--r--Source/Core/DiscIO/VolumeWad.h1
4 files changed, 11 insertions, 0 deletions
diff --git a/Source/Core/DiscIO/Volume.h b/Source/Core/DiscIO/Volume.h
index 7dfabb3e97..61df7e032f 100644
--- a/Source/Core/DiscIO/Volume.h
+++ b/Source/Core/DiscIO/Volume.h
@@ -126,6 +126,7 @@ public:
}
virtual Region GetRegion() const = 0;
virtual Country GetCountry(const Partition& partition = PARTITION_NONE) const = 0;
+ virtual u32 GetSimulatedMemorySize() const = 0;
virtual BlobType GetBlobType() const = 0;
// Size of virtual disc (may be inaccurate depending on the blob type)
virtual u64 GetDataSize() const = 0;
diff --git a/Source/Core/DiscIO/VolumeDisc.cpp b/Source/Core/DiscIO/VolumeDisc.cpp
index e842540376..4dd16c4cef 100644
--- a/Source/Core/DiscIO/VolumeDisc.cpp
+++ b/Source/Core/DiscIO/VolumeDisc.cpp
@@ -179,6 +179,14 @@ std::optional<u8> VolumeDisc::GetDiscNumber(const Partition& partition) const
return ReadSwapped<u8>(6, partition);
}
+u32 VolumeDisc::GetSimulatedMemorySize() const
+{
+ // Simulated memory size is a 32-bit unsigned integer in the `bi2.bin` file at offset `0x04`.
+ // Apploader reads this and "simulates" a smaller memory size. Originally useful for simulating
+ // 24 MiB of memory on devkits with 48 MiB.
+ return ReadSwapped<u32>(BI2_ADDRESS + 0x04, GetGamePartition()).value_or(0);
+}
+
bool VolumeDisc::IsNKit() const
{
constexpr u32 NKIT_MAGIC = 0x4E4B4954; // "NKIT"
diff --git a/Source/Core/DiscIO/VolumeDisc.h b/Source/Core/DiscIO/VolumeDisc.h
index f630522e68..1b3774a87d 100644
--- a/Source/Core/DiscIO/VolumeDisc.h
+++ b/Source/Core/DiscIO/VolumeDisc.h
@@ -47,6 +47,7 @@ public:
std::string GetInternalName(const Partition& partition = PARTITION_NONE) const override;
std::string GetApploaderDate(const Partition& partition) const override;
std::optional<u8> GetDiscNumber(const Partition& partition = PARTITION_NONE) const override;
+ u32 GetSimulatedMemorySize() const override;
bool IsNKit() const override;
protected:
diff --git a/Source/Core/DiscIO/VolumeWad.h b/Source/Core/DiscIO/VolumeWad.h
index 2c383c0254..88a0847f80 100644
--- a/Source/Core/DiscIO/VolumeWad.h
+++ b/Source/Core/DiscIO/VolumeWad.h
@@ -61,6 +61,7 @@ public:
bool IsNKit() const override;
Region GetRegion() const override;
Country GetCountry(const Partition& partition = PARTITION_NONE) const override;
+ u32 GetSimulatedMemorySize() const override { return 0; }
BlobType GetBlobType() const override;
u64 GetDataSize() const override;