Skip to content

Commit

Permalink
Adds the ability to read a amiibo's nickname from the VirtualAmiiboFi…
Browse files Browse the repository at this point in the history
…le (Ryubing#217)

This feature adds a way to change the Amiibo's nickname inside Smash and
other places where it's used, so it’s not always "Ryujinx." However, I
did not add a GUI or create the Cabinet applet that would allow users to
change this. So you will have to go to system/amiibo and find your
amiibo id to change it.
  • Loading branch information
Jacobwasbeast authored and marco-carvalho committed Jan 5, 2025
1 parent c19d219 commit c7c4b88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct VirtualAmiiboFile
public uint FileVersion { get; set; }
public byte[] TagUuid { get; set; }
public string AmiiboId { get; set; }
public string NickName { get; set; }
public DateTime FirstWriteDate { get; set; }
public DateTime LastWriteDate { get; set; }
public ushort WriteCounter { get; set; }
Expand Down
11 changes: 7 additions & 4 deletions src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ public static CommonInfo GetCommonInfo(string amiiboId)
};
}

public static RegisterInfo GetRegisterInfo(ITickSource tickSource, string amiiboId, string nickname)
public static RegisterInfo GetRegisterInfo(ITickSource tickSource, string amiiboId, string userName)
{
VirtualAmiiboFile amiiboFile = LoadAmiiboFile(amiiboId);

string nickname = amiiboFile.NickName ?? "Ryujinx";
UtilityImpl utilityImpl = new(tickSource);
CharInfo charInfo = new();

charInfo.SetFromStoreData(StoreData.BuildDefault(utilityImpl, 0));

charInfo.Nickname = Nickname.FromString(nickname);
// This is the player's name
charInfo.Nickname = Nickname.FromString(userName);

RegisterInfo registerInfo = new()
{
Expand All @@ -85,7 +86,9 @@ public static RegisterInfo GetRegisterInfo(ITickSource tickSource, string amiibo
Reserved1 = new Array64<byte>(),
Reserved2 = new Array58<byte>(),
};
"Ryujinx"u8.CopyTo(registerInfo.Nickname.AsSpan());
// This is the amiibo's name
byte[] nicknameBytes = System.Text.Encoding.UTF8.GetBytes(nickname);
nicknameBytes.CopyTo(registerInfo.Nickname.AsSpan());

return registerInfo;
}
Expand Down

0 comments on commit c7c4b88

Please sign in to comment.