Skip to content

Commit

Permalink
Version 1.5
Browse files Browse the repository at this point in the history
Fixed Space Jump Boots querying wrong place in memory
IGT now doesn't appear anymore on Title Screen
Icons display at the bottom while in Morphed state
  • Loading branch information
UltiNaruto committed Jul 21, 2020
1 parent fc3042d commit 83e27f6
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 6 deletions.
31 changes: 31 additions & 0 deletions MPItemTracker/Memory/Constants/MP1_NTSC_1_00.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ internal class MP1_NTSC_1_00 : _MP1
internal const long OFF_CSTATEMANAGER = 0x45A1A8;
internal const long OFF_MORPHBALLBOMBS_COUNT = 0x457D1B;

internal override long CPlayer
{
get
{
long result = Dolphin.ReadUInt32(GC.RAMBaseAddress + OFF_CSTATEMANAGER + OFF_CPLAYER);
if (result < GC.RAMBaseAddress)
return -1;
return result;
}
}

internal override long CGameState
{
get
Expand Down Expand Up @@ -58,6 +69,26 @@ internal override string IGTAsStr
}
}

internal override bool IsMorphed
{
get
{
if (CPlayer == -1)
return false;
return Dolphin.ReadUInt32(CPlayer + OFF_CPLAYER_MORPHSTATE) == 1;
}
}

internal override bool IsSwitchingState
{
get
{
if (CPlayer == -1)
return false;
return Dolphin.ReadUInt32(CPlayer + OFF_CPLAYER_SWITCHSTATE) == 5;
}
}

internal override int MaxMissiles
{
get
Expand Down
31 changes: 31 additions & 0 deletions MPItemTracker/Memory/Constants/MP1_NTSC_1_02.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ internal class MP1_NTSC_1_02 : _MP1
internal const long OFF_CSTATEMANAGER = 0x45B208;
internal const long OFF_MORPHBALLBOMBS_COUNT = 0x458D7B;

internal override long CPlayer
{
get
{
long result = Dolphin.ReadUInt32(GC.RAMBaseAddress + OFF_CSTATEMANAGER + OFF_CPLAYER);
if (result < GC.RAMBaseAddress)
return -1;
return result;
}
}

internal override long CGameState
{
get
Expand Down Expand Up @@ -58,6 +69,26 @@ internal override string IGTAsStr
}
}

internal override bool IsMorphed
{
get
{
if (CPlayer == -1)
return false;
return Dolphin.ReadUInt32(CPlayer + OFF_CPLAYER_MORPHSTATE) == 1;
}
}

internal override bool IsSwitchingState
{
get
{
if (CPlayer == -1)
return false;
return Dolphin.ReadUInt32(CPlayer + OFF_CPLAYER_SWITCHSTATE) == 5;
}
}

internal override int MaxMissiles
{
get
Expand Down
30 changes: 30 additions & 0 deletions MPItemTracker/Memory/Constants/MP1_PAL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ internal class MP1_PAL : _MP1
internal const long OFF_CSTATEMANAGER = 0x3E2088;
internal const long OFF_MORPHBALLBOMBS_COUNT = 0x3DFBFB;

internal override long CPlayer
{
get
{
long result = Dolphin.ReadUInt32(GC.RAMBaseAddress + OFF_CSTATEMANAGER + OFF_CPLAYER);
if (result < GC.RAMBaseAddress)
return -1;
return result;
}
}

internal override long CGameState
{
get
Expand Down Expand Up @@ -58,6 +69,25 @@ internal override string IGTAsStr
}
}

internal override bool IsMorphed {
get
{
if (CPlayer == -1)
return false;
return Dolphin.ReadUInt32(CPlayer + OFF_CPLAYER_MORPHSTATE) == 1;
}
}

internal override bool IsSwitchingState
{
get
{
if (CPlayer == -1)
return false;
return Dolphin.ReadUInt8(CPlayer + OFF_CPLAYER_SWITCHSTATE) == 5;
}
}

internal override int MaxMissiles
{
get
Expand Down
9 changes: 8 additions & 1 deletion MPItemTracker/Memory/Constants/_MP1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
internal abstract class _MP1
{
internal const long OFF_PLAYTIME = 0xA0;
internal const long OFF_CPLAYER_MORPHSTATE = 0x68;
internal const long OFF_CPLAYER_SWITCHSTATE = 0xB4;
internal const long OFF_CPLAYER = 0x84C;
internal const long OFF_CWORLD = 0x850;
internal const long OFF_ROOM_ID = 0x68;
internal const long OFF_WORLD_ID = 0x6C;
Expand All @@ -26,7 +29,7 @@ internal abstract class _MP1
internal const long OFF_GRAPPLEBEAM_OBTAINED = 0x8F;
internal const long OFF_XRAYVISOR_OBTAINED = 0x97;
internal const long OFF_ICESPREADER_OBTAINED = 0x9F;
internal const long OFF_SPACEJUMPBOOTS_OBTAINED = 0xA7;
internal const long OFF_SPACEJUMPBOOTS_OBTAINED = 0xA3;
internal const long OFF_MORPHBALL_OBTAINED = 0xAF;
internal const long OFF_COMBATVISOR_OBTAINED = 0xB7;
internal const long OFF_BOOSTBALL_OBTAINED = 0xBF;
Expand All @@ -51,11 +54,15 @@ internal abstract class _MP1
internal const long OFF_ARTIFACT_OF_SPIRIT_OBTAINED = 0x167;
internal const long OFF_ARTIFACT_OF_NEWBORN_OBTAINED = 0x16F;

internal abstract long CPlayer { get; }
internal abstract long CGameState { get; }
internal abstract long CPlayerState { get; }
internal abstract long IGT { get; }
internal abstract string IGTAsStr { get; }

internal abstract bool IsMorphed { get; }
internal abstract bool IsSwitchingState { get; }

internal abstract int MaxMissiles { get; }
internal abstract int MaxPowerBombs { get; }

Expand Down
14 changes: 9 additions & 5 deletions MPItemTracker/Memory/Dolphin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,13 @@ internal static void UpdateTracker(Graphics g)
KeyValuePair<Point, Size> gameWindowPosAndSize = Dolphin.GetDolphinGameWindowPosAndSize();
if (MetroidPrime.CGameState == -1)
return;
DrawIGT(g, gameWindowPosAndSize.Value);
foreach (KeyValuePair<String, Image> kvp in img)
DrawUpgradeIcon(g, gameWindowPosAndSize.Value, kvp.Key);
if (Dolphin.MetroidPrime.IGT > 0)
{
DrawIGT(g, gameWindowPosAndSize.Value);
if(!MetroidPrime.IsSwitchingState)
foreach (KeyValuePair<String, Image> kvp in img)
DrawUpgradeIcon(g, gameWindowPosAndSize.Value, kvp.Key);
}
}

internal static void UpdateTrackerInfo(MPItemTracker.Form1 form)
Expand Down Expand Up @@ -367,10 +371,10 @@ internal static void DrawUpgradeIcon(Graphics g, Size windowSize, String upgrade
if (!img.ContainsKey(upgrade_title))
return;

g.DrawImage(img[upgrade_title], x, 5, imgSize, imgSize);
g.DrawImage(img[upgrade_title], x, MetroidPrime.IsMorphed ? windowSize.Height - imgSize * 2 - 10 : 5, imgSize, imgSize);

if(displayText != "x")
g.DrawString(displayText, _Font, Brushes.White, x + 0.6f * imgSize, 5 + imgSize);
g.DrawString(displayText, _Font, Brushes.White, x + 0.6f * imgSize, MetroidPrime.IsMorphed ? windowSize.Height - imgSize - 7 : 5 + imgSize);
}

internal static Byte[] Read(long gc_address, int size, bool BigEndian = false)
Expand Down

0 comments on commit 83e27f6

Please sign in to comment.