Skip to content

Commit

Permalink
Updated read/write cards functions from spirolone
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueRaja committed Jan 29, 2017
1 parent ba6f185 commit fe2c6fd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/com/blueraja/magicduelsimporter/magicduels/Profile.java
Expand Up @@ -28,21 +28,21 @@ public Profile(File profileFile) throws FileNotFoundException, IOException {
content[i] ^= content[i-1];
content[0x45A] ^= content[0x459+fieldLen];
}

public byte[] readCards(int numCards) {
byte[] cards = new byte[numCards+1];
int offset = (content[0x45E] & 0xFF) + ((content[0x45F] & 0xFF)<<8) + 0x4E0;
for (int i=0; i<numCards/2; i++) {
byte[] cards = new byte[numCards];
int offset = content.length - 1026;
for (int i=0; i<=numCards/2; i++) {
cards[2*i] = (byte)(content[offset+i] & 0x0F);
if(2*i+1 < cards.length) {
cards[2*i+1] = (byte) ((content[offset + i]>>4) & 0x0F);
}
}
return cards;
}

public void writeCards(byte[] cards) {
int offset = (content[0x45E] & 0xFF) + ((content[0x45F] & 0xFF)<<8) + 0x4E0;
int offset = content.length - 1026;
for (int i=0; i<(cards.length/2); i++)
content[offset+i] = (byte)((cards[2*i] & 0x0F) + ((cards[2*i+1]<<4) & 0xF0));
}
Expand Down

0 comments on commit fe2c6fd

Please sign in to comment.