add some kind of 3DS support to retroachievements, probably

This commit is contained in:
CasualPokePlayer 2023-08-12 04:22:46 -07:00
parent 72cc192661
commit 4ad7736ca7
4 changed files with 24 additions and 3 deletions

View File

@ -15,7 +15,7 @@ namespace BizHawk.Client.EmuHawk
{
public partial class RCheevos : RetroAchievements
{
private static readonly LibRCheevos _lib;
internal static readonly LibRCheevos _lib;
static RCheevos()
{

View File

@ -130,6 +130,7 @@ namespace BizHawk.Client.EmuHawk
VSystemID.Raw.Libretro => ConsoleID.UnknownConsoleID,
VSystemID.Raw.Lynx => ConsoleID.Lynx,
VSystemID.Raw.MSX => ConsoleID.MSX,
VSystemID.Raw.N3DS => ConsoleID.Nintendo3DS,
VSystemID.Raw.N64 => ConsoleID.N64,
VSystemID.Raw.NDS when Emu is NDS { IsDSi: true } => ConsoleID.DSi,
VSystemID.Raw.NDS => ConsoleID.DS,

View File

@ -284,6 +284,14 @@ namespace BizHawk.Client.EmuHawk
return IdentifyHash(hash);
}
private int Hash3DS(string path)
{
// 3DS is too big to hash as a byte array...
var hash = new byte[33];
return RCheevos._lib.rc_hash_generate_from_file(hash, ConsoleID.Nintendo3DS, path)
? IdentifyHash(Encoding.ASCII.GetString(hash, 0, 32)) : 0;
}
protected IReadOnlyList<int> GetRAGameIds(IOpenAdvanced ioa, ConsoleID consoleID)
{
var ret = new List<int>();
@ -303,7 +311,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (ext == ".xml")
{
var xml = XmlGame.Create(new HawkFile(ioa.SimplePath));
var xml = XmlGame.Create(new(ioa.SimplePath));
foreach (var kvp in xml.Assets)
{
if (consoleID is ConsoleID.Arcade)
@ -312,6 +320,12 @@ namespace BizHawk.Client.EmuHawk
break;
}
if (consoleID is ConsoleID.Nintendo3DS)
{
ret.Add(Hash3DS(kvp.Key));
break;
}
ret.Add(Disc.IsValidExtension(Path.GetExtension(kvp.Key))
? HashDisc(kvp.Key, consoleID)
: IdentifyRom(kvp.Value));
@ -325,6 +339,12 @@ namespace BizHawk.Client.EmuHawk
break;
}
if (consoleID is ConsoleID.Nintendo3DS)
{
ret.Add(Hash3DS(ioa.SimplePath));
break;
}
if (Disc.IsValidExtension(Path.GetExtension(ext)))
{
ret.Add(HashDisc(ioa.SimplePath, consoleID));

View File

@ -363,7 +363,7 @@ namespace BizHawk.Client.EmuHawk
ConsoleID.PlayStation, ConsoleID.Lynx, ConsoleID.Lynx, ConsoleID.NeoGeoPocket,
ConsoleID.Jaguar, ConsoleID.JaguarCD, ConsoleID.DS, ConsoleID.DSi,
ConsoleID.AppleII, ConsoleID.Vectrex, ConsoleID.Tic80, ConsoleID.PCEngine,
ConsoleID.Uzebox,
ConsoleID.Uzebox, ConsoleID.Nintendo3DS,
};
// these consoles will use part of the system bus at an offset