Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed card save from slot #403

Merged
merged 5 commits into from
Dec 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions chameleonultragui/lib/gui/menu/slot_export.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,39 @@ class SlotExportMenuState extends State<SlotExportMenu> {
);
} else {
CardData data = await appState.communicator!.mf1GetAntiCollData();
List<Uint8List> binData = [];

int blockCount = mfClassicGetBlockCount(
chameleonTagTypeGetMfClassicType(widget.slotTypes.hf));
for (int block = 0; block < blockCount; block += 16) {
Uint8List blockData =
await appState.communicator!.mf1GetEmulatorBlock(block, block + 16);
binData.add(blockData);

Uint8List binData = Uint8List(blockCount * 16);

// How many blocks to request per read command.
int readCount = 16;
int binDataIndex = 0;

for (int currentBlock = 0;
currentBlock < blockCount;
currentBlock += readCount) {
Uint8List result = await appState.communicator!
.mf1GetEmulatorBlock(currentBlock, readCount);

binData.setAll(binDataIndex, result);
binDataIndex += result.length;
}

int remainingBlocks = blockCount % readCount;

if (remainingBlocks != 0) {
Uint8List result = await appState.communicator!
.mf1GetEmulatorBlock(blockCount - remainingBlocks, remainingBlocks);
binData.setAll(binDataIndex, result);
}

List<Uint8List> blocks = [];

for (int i = 0; i < binData.length; i += 16) {
Uint8List block = Uint8List.fromList(binData.sublist(i, i+16));
blocks.add(block);
}

return CardSave(
Expand All @@ -66,7 +91,7 @@ class SlotExportMenuState extends State<SlotExportMenu> {
atqa: data.atqa,
ats: data.ats,
tag: widget.slotTypes.hf,
data: binData,
data: blocks,
);
}
}
Expand Down
Loading