diff --git a/AMNet.Server/DllMain.cs b/AMNet.Server/DllMain.cs index 248ded4..c20096d 100644 --- a/AMNet.Server/DllMain.cs +++ b/AMNet.Server/DllMain.cs @@ -111,7 +111,7 @@ public static class DllMain } [UnmanagedCallersOnly(EntryPoint = "aime_io_nfc_get_felica_id")] - public static int GetFelicaId(byte unitNo, IntPtr idm) + public static unsafe int GetFelicaId(byte unitNo, ulong* idm) { if (!Config.PhysicalCardUseIDm || unitNo != 0) { @@ -123,8 +123,14 @@ public static class DllMain { return 1; } - - Marshal.Copy(card.IDm, 0, idm, sizeof(ulong)); + + ulong idmValue = 0; + for (var i = 0 ; i < 8 ; i++) { + idmValue = (idmValue << 8) | card.IDm[i]; + } + + *idm = idmValue; + App.Logger.LogInformation("FeliCa IDm read: {idm}", CardPresenter.FormatHexCode(card.IDm)); return 0; } diff --git a/readme.md b/readme.md index 81d176f..f68f7cd 100644 --- a/readme.md +++ b/readme.md @@ -38,10 +38,15 @@ This was originally intended for use with maimai and CHUNITHM, but should be com ### Physical Cards AMNet 1.3 adds support for scanning physical cards on iOS devices. If you own a physical AiMe/Banapass/e-Amusement/Suica card, you can scan it using the app and use it in-game. -By changing the `useAimeDBForPhysicalCards` in segatools.ini, it is also possible to adjust the format of card numbers sent to the game: +By changing the `useAimeDBForPhysicalCards` in segatools.ini, you can choose how the card is read on a per-game basis: -- `0` - Default value, will send the 20-digit access code on the back of the card to the game and load the save data directly. -- `1` - Send the card's IDm data to the game, and it will use the connected AiMeDB to retrieve a 20 digit code assigned to the card. This option should be used on shared networks to enable the same account data/profile as you would get on a physical cab. +- `0` will send the 20-digit access code on the back of the card to the game and load the save data directly (default option). +- `1` - Send the card's IDm to the game and use AiMeDB to retrieve the 20-digit code assigned to the card. + +Mode `1` makes the app function in the same way to a real card reader and should be used if you want the same access code to show when scanning the card on a cab. +You should also use this option if you're connecting to a hosted server (AquaNet/rinnet/etc). + +Additionally, if `useAimeDBForPhysicalCards` is set to `1` and the game is failing to read the card, make sure an up-to-date version of segatools is being used. ## Interfaces AMNet can be used on most platforms, see below for options available for each platform: