more changes from u8[] to u16/u32
Signed-off-by: LPFaint99 <lpfaint99@gmail.com>
This commit is contained in:
parent
ebdab914cb
commit
e68b892cc6
|
@ -595,7 +595,7 @@ bool GCMemcard::BlockAlloc::ClearBlocks(u16 FirstBlock, u16 BlockCount)
|
|||
}
|
||||
for (int i = 0; i < length; ++i)
|
||||
Map[blocks.at(i)-MC_FST_BLOCKS] = 0;
|
||||
*(u16*)&FreeBlocks = BE16(BE16(FreeBlocks) + BlockCount);
|
||||
FreeBlocks = BE16(BE16(FreeBlocks) + BlockCount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -646,10 +646,7 @@ u32 GCMemcard::ImportFile(DEntry& direntry, std::vector<GCMBlock> &saveBlocks)
|
|||
return TITLEPRESENT;
|
||||
}
|
||||
|
||||
// find first free data block -- assume no freespace fragmentation
|
||||
//int totalspace = (((u32)BE16(hdr.SizeMb) * MBIT_TO_BLOCKS) - MC_FST_BLOCKS);
|
||||
//int firstFree1 = BE16(bat.LastAllocated) + 1;
|
||||
|
||||
// find first free data block
|
||||
u16 firstBlock = CurrentBat->NextFreeBlock();
|
||||
|
||||
Directory UpdatedDir = *CurrentDir;
|
||||
|
@ -696,7 +693,7 @@ u32 GCMemcard::ImportFile(DEntry& direntry, std::vector<GCMBlock> &saveBlocks)
|
|||
UpdatedBat.Map[firstBlock - MC_FST_BLOCKS] = BE16(nextBlock);
|
||||
firstBlock = nextBlock;
|
||||
}
|
||||
*(u16*)&UpdatedBat.FreeBlocks = BE16(BE16(UpdatedBat.FreeBlocks) - fileBlocks);
|
||||
UpdatedBat.FreeBlocks = BE16(BE16(UpdatedBat.FreeBlocks) - fileBlocks);
|
||||
UpdatedBat.UpdateCounter = BE16(BE16(UpdatedBat.UpdateCounter) + 1);
|
||||
*PreviousBat = UpdatedBat;
|
||||
if (PreviousBat == &bat )
|
||||
|
@ -1235,8 +1232,8 @@ void GCMemcard::FormatInternal(GCMC_Header &GCP)
|
|||
rand = (((rand * (u64)0x0000000041c64e6dULL) + (u64)0x0000000000003039ULL) >> 16);
|
||||
rand &= (u64)0x0000000000007fffULL;
|
||||
}
|
||||
*(u32*)&p_hdr->SramBias = g_SRAM.counter_bias;
|
||||
*(u32*)&p_hdr->SramLang = g_SRAM.lang;
|
||||
p_hdr->SramBias = g_SRAM.counter_bias;
|
||||
p_hdr->SramLang = g_SRAM.lang;
|
||||
// TODO: determine the purpose of Unk2 1 works for slot A, 0 works for both slot A and slot B
|
||||
*(u32*)&p_hdr->Unk2 = 0; // = _viReg[55]; static vu16* const _viReg = (u16*)0xCC002000;
|
||||
*(u16*)&p_hdr->deviceID = 0;
|
||||
|
@ -1252,8 +1249,8 @@ void GCMemcard::FormatInternal(GCMC_Header &GCP)
|
|||
BlockAlloc *p_bat = GCP.bat,
|
||||
*p_bat_backup = GCP.bat_backup;
|
||||
p_bat_backup->UpdateCounter = BE16(1);
|
||||
*(u16*)&p_bat->FreeBlocks = *(u16*)&p_bat_backup->FreeBlocks = BE16(( BE16(p_hdr->SizeMb) * MBIT_TO_BLOCKS) - MC_FST_BLOCKS);
|
||||
*(u16*)&p_bat->LastAllocated = *(u16*)&p_bat_backup->LastAllocated = BE16(4);
|
||||
p_bat->FreeBlocks = *(u16*)&p_bat_backup->FreeBlocks = BE16(( BE16(p_hdr->SizeMb) * MBIT_TO_BLOCKS) - MC_FST_BLOCKS);
|
||||
p_bat->LastAllocated = p_bat_backup->LastAllocated = BE16(4);
|
||||
calc_checksumsBE((u16*)p_bat+2, 0xFFE, &p_bat->Checksum, &p_bat->Checksum_Inv);
|
||||
calc_checksumsBE((u16*)p_bat_backup+2, 0xFFE, &p_bat_backup->Checksum, &p_bat_backup->Checksum_Inv);
|
||||
}
|
||||
|
|
|
@ -89,15 +89,15 @@ private:
|
|||
// Serial in libogc
|
||||
u8 serial[12]; //0x0000 12 ?
|
||||
u64 formatTime; //0x000c 8 time of format (OSTime value)
|
||||
u8 SramBias[4]; //0x0014 4 sram bias at time of format
|
||||
u8 SramLang[4]; //0x0018 4 sram language
|
||||
u32 SramBias; //0x0014 4 sram bias at time of format
|
||||
u32 SramLang; //0x0018 4 sram language
|
||||
u8 Unk2[4]; //0x001c 4 ? almost always 0
|
||||
// end Serial in libogc
|
||||
u8 deviceID[2]; //0x0020 2 0 if formated in slot A 1 if formated in slot B
|
||||
u8 SizeMb[2]; //0x0022 2 size of memcard in Mbits
|
||||
u16 Encoding; //0x0024 2 encoding (ASCII or japanese)
|
||||
u8 Unused1[468]; //0x0026 468 unused (0xff)
|
||||
u16 UpdateCounter;//0x01fa 2 update Counter (?, probably unused)
|
||||
u16 UpdateCounter; //0x01fa 2 update Counter (?, probably unused)
|
||||
u16 Checksum; //0x01fc 2 Additive Checksum
|
||||
u16 Checksum_Inv; //0x01fe 2 Inverse Checksum
|
||||
u8 Unused2[7680]; //0x0200 0x1e00 unused (0xff)
|
||||
|
@ -158,11 +158,11 @@ private:
|
|||
|
||||
Directory *CurrentDir, *PreviousDir;
|
||||
struct BlockAlloc {
|
||||
u16 Checksum; //0x0000 2 Additive Checksum
|
||||
u16 Checksum_Inv; //0x0002 2 Inverse Checksum
|
||||
u16 UpdateCounter; //0x0004 2 update Counter
|
||||
u8 FreeBlocks[2]; //0x0006 2 free Blocks
|
||||
u8 LastAllocated[2];//0x0008 2 last allocated Block
|
||||
u16 Checksum; //0x0000 2 Additive Checksum
|
||||
u16 Checksum_Inv; //0x0002 2 Inverse Checksum
|
||||
u16 UpdateCounter; //0x0004 2 update Counter
|
||||
u16 FreeBlocks; //0x0006 2 free Blocks
|
||||
u16 LastAllocated; //0x0008 2 last allocated Block
|
||||
u16 Map[BAT_SIZE]; //0x000a 0x1ff8 Map of allocated Blocks
|
||||
u16 GetNextBlock(u16 Block) const;
|
||||
u16 NextFreeBlock(u16 StartingBlock=MC_FST_BLOCKS) const;
|
||||
|
|
Loading…
Reference in New Issue