mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-11 08:39:13 +01:00
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)
|
for (int i = 0; i < length; ++i)
|
||||||
Map[blocks.at(i)-MC_FST_BLOCKS] = 0;
|
Map[blocks.at(i)-MC_FST_BLOCKS] = 0;
|
||||||
*(u16*)&FreeBlocks = BE16(BE16(FreeBlocks) + BlockCount);
|
FreeBlocks = BE16(BE16(FreeBlocks) + BlockCount);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -646,10 +646,7 @@ u32 GCMemcard::ImportFile(DEntry& direntry, std::vector<GCMBlock> &saveBlocks)
|
|||||||
return TITLEPRESENT;
|
return TITLEPRESENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find first free data block -- assume no freespace fragmentation
|
// find first free data block
|
||||||
//int totalspace = (((u32)BE16(hdr.SizeMb) * MBIT_TO_BLOCKS) - MC_FST_BLOCKS);
|
|
||||||
//int firstFree1 = BE16(bat.LastAllocated) + 1;
|
|
||||||
|
|
||||||
u16 firstBlock = CurrentBat->NextFreeBlock();
|
u16 firstBlock = CurrentBat->NextFreeBlock();
|
||||||
|
|
||||||
Directory UpdatedDir = *CurrentDir;
|
Directory UpdatedDir = *CurrentDir;
|
||||||
@ -696,7 +693,7 @@ u32 GCMemcard::ImportFile(DEntry& direntry, std::vector<GCMBlock> &saveBlocks)
|
|||||||
UpdatedBat.Map[firstBlock - MC_FST_BLOCKS] = BE16(nextBlock);
|
UpdatedBat.Map[firstBlock - MC_FST_BLOCKS] = BE16(nextBlock);
|
||||||
firstBlock = 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);
|
UpdatedBat.UpdateCounter = BE16(BE16(UpdatedBat.UpdateCounter) + 1);
|
||||||
*PreviousBat = UpdatedBat;
|
*PreviousBat = UpdatedBat;
|
||||||
if (PreviousBat == &bat )
|
if (PreviousBat == &bat )
|
||||||
@ -1235,8 +1232,8 @@ void GCMemcard::FormatInternal(GCMC_Header &GCP)
|
|||||||
rand = (((rand * (u64)0x0000000041c64e6dULL) + (u64)0x0000000000003039ULL) >> 16);
|
rand = (((rand * (u64)0x0000000041c64e6dULL) + (u64)0x0000000000003039ULL) >> 16);
|
||||||
rand &= (u64)0x0000000000007fffULL;
|
rand &= (u64)0x0000000000007fffULL;
|
||||||
}
|
}
|
||||||
*(u32*)&p_hdr->SramBias = g_SRAM.counter_bias;
|
p_hdr->SramBias = g_SRAM.counter_bias;
|
||||||
*(u32*)&p_hdr->SramLang = g_SRAM.lang;
|
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
|
// 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;
|
*(u32*)&p_hdr->Unk2 = 0; // = _viReg[55]; static vu16* const _viReg = (u16*)0xCC002000;
|
||||||
*(u16*)&p_hdr->deviceID = 0;
|
*(u16*)&p_hdr->deviceID = 0;
|
||||||
@ -1252,8 +1249,8 @@ void GCMemcard::FormatInternal(GCMC_Header &GCP)
|
|||||||
BlockAlloc *p_bat = GCP.bat,
|
BlockAlloc *p_bat = GCP.bat,
|
||||||
*p_bat_backup = GCP.bat_backup;
|
*p_bat_backup = GCP.bat_backup;
|
||||||
p_bat_backup->UpdateCounter = BE16(1);
|
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);
|
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->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+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);
|
calc_checksumsBE((u16*)p_bat_backup+2, 0xFFE, &p_bat_backup->Checksum, &p_bat_backup->Checksum_Inv);
|
||||||
}
|
}
|
||||||
|
@ -89,8 +89,8 @@ private:
|
|||||||
// Serial in libogc
|
// Serial in libogc
|
||||||
u8 serial[12]; //0x0000 12 ?
|
u8 serial[12]; //0x0000 12 ?
|
||||||
u64 formatTime; //0x000c 8 time of format (OSTime value)
|
u64 formatTime; //0x000c 8 time of format (OSTime value)
|
||||||
u8 SramBias[4]; //0x0014 4 sram bias at time of format
|
u32 SramBias; //0x0014 4 sram bias at time of format
|
||||||
u8 SramLang[4]; //0x0018 4 sram language
|
u32 SramLang; //0x0018 4 sram language
|
||||||
u8 Unk2[4]; //0x001c 4 ? almost always 0
|
u8 Unk2[4]; //0x001c 4 ? almost always 0
|
||||||
// end Serial in libogc
|
// end Serial in libogc
|
||||||
u8 deviceID[2]; //0x0020 2 0 if formated in slot A 1 if formated in slot B
|
u8 deviceID[2]; //0x0020 2 0 if formated in slot A 1 if formated in slot B
|
||||||
@ -161,8 +161,8 @@ private:
|
|||||||
u16 Checksum; //0x0000 2 Additive Checksum
|
u16 Checksum; //0x0000 2 Additive Checksum
|
||||||
u16 Checksum_Inv; //0x0002 2 Inverse Checksum
|
u16 Checksum_Inv; //0x0002 2 Inverse Checksum
|
||||||
u16 UpdateCounter; //0x0004 2 update Counter
|
u16 UpdateCounter; //0x0004 2 update Counter
|
||||||
u8 FreeBlocks[2]; //0x0006 2 free Blocks
|
u16 FreeBlocks; //0x0006 2 free Blocks
|
||||||
u8 LastAllocated[2];//0x0008 2 last allocated Block
|
u16 LastAllocated; //0x0008 2 last allocated Block
|
||||||
u16 Map[BAT_SIZE]; //0x000a 0x1ff8 Map of allocated Blocks
|
u16 Map[BAT_SIZE]; //0x000a 0x1ff8 Map of allocated Blocks
|
||||||
u16 GetNextBlock(u16 Block) const;
|
u16 GetNextBlock(u16 Block) const;
|
||||||
u16 NextFreeBlock(u16 StartingBlock=MC_FST_BLOCKS) const;
|
u16 NextFreeBlock(u16 StartingBlock=MC_FST_BLOCKS) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user