Skip to content
This repository has been archived by the owner on Jul 30, 2023. It is now read-only.

Commit

Permalink
add mpcore private memory
Browse files Browse the repository at this point in the history
  • Loading branch information
Starlet Lockhomes committed Sep 4, 2018
1 parent 3f24171 commit 738300b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions LemonLime.LLE/Memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Memory : IBus

private byte[] ARM9_InternalMemory = new byte[0x00100000];

private byte[] MPCore_PrivateMemory = new byte[0x00002000];

private byte[] AXIWRAM = new byte[0x00080000];

private byte[] FCRAM = new byte[0x08000000];
Expand Down Expand Up @@ -76,7 +78,7 @@ public byte ReadUInt8(uint Address)
{
if (Address >= 0x17E00000 && Address < 0x17E00000 + 0x00002000)
{
return 0;
return MPCore_PrivateMemory[Address - 0x17E00000];
}
}

Expand Down Expand Up @@ -129,7 +131,8 @@ public ushort ReadUInt16(uint Address)
{
if (Address >= 0x17E00000 && Address < 0x17E00000 + 0x00002000)
{
return 0;
return (ushort)(ReadUInt8(Address) |
(ReadUInt8(Address + 1) << 8));
}
}

Expand All @@ -150,7 +153,10 @@ public uint ReadUInt32(uint Address)
{
if (Address >= 0x17E00000 && Address < 0x17E00000 + 0x00002000)
{
return 0;
return (uint)(ReadUInt8(Address) |
(ReadUInt8(Address + 1) << 8) |
(ReadUInt8(Address + 2) << 16) |
(ReadUInt8(Address + 3) << 24));
}
}

Expand Down Expand Up @@ -187,6 +193,7 @@ public void WriteUInt8(uint Address, byte Value)
{
if (Address >= 0x17E00000 && Address < 0x17E00000 + 0x00002000)
{
MPCore_PrivateMemory[Address - 0x17E00000] = Value;
return;
}
}
Expand Down Expand Up @@ -225,6 +232,8 @@ public void WriteUInt16(uint Address, ushort Value)
{
if (Address >= 0x17E00000 && Address < 0x17E00000 + 0x00002000)
{
WriteUInt8(Address, (byte)Value);
WriteUInt8(Address + 1, (byte)(Value >> 8));
return;
}
}
Expand All @@ -245,6 +254,10 @@ public void WriteUInt32(uint Address, uint Value)
{
if (Address >= 0x17E00000 && Address < 0x17E00000 + 0x00002000)
{
WriteUInt8(Address, (byte)Value);
WriteUInt8(Address + 1, (byte)(Value >> 8));
WriteUInt8(Address + 2, (byte)(Value >> 16));
WriteUInt8(Address + 3, (byte)(Value >> 24));
return;
}
}
Expand Down

0 comments on commit 738300b

Please sign in to comment.