Core: Correct some function casings.

This commit is contained in:
Lioncash 2014-07-15 19:29:42 -04:00
parent 79e90a1521
commit 6c57457f9f
15 changed files with 92 additions and 86 deletions

View File

@ -24,7 +24,7 @@ static int changeDevice;
static CEXIChannel *g_Channels[MAX_EXI_CHANNELS];
void Init()
{
initSRAM();
InitSRAM();
for (u32 i = 0; i < MAX_EXI_CHANNELS; i++)
g_Channels[i] = new CEXIChannel(i);

View File

@ -88,11 +88,11 @@ CEXIMemoryCard::CEXIMemoryCard(const int index, bool gciFolder)
if (gciFolder)
{
setupGciFolder(sizeMb);
SetupGciFolder(sizeMb);
}
else
{
setupRawMemcard(sizeMb);
SetupRawMemcard(sizeMb);
}
memory_card_size = memorycard->GetCardId() * SIZE_TO_Mb;
@ -101,7 +101,7 @@ CEXIMemoryCard::CEXIMemoryCard(const int index, bool gciFolder)
SetCardFlashID(header, card_index);
}
void CEXIMemoryCard::setupGciFolder(u16 sizeMb)
void CEXIMemoryCard::SetupGciFolder(u16 sizeMb)
{
DiscIO::IVolume::ECountry CountryCode = DiscIO::IVolume::COUNTRY_UNKNOWN;
@ -163,7 +163,7 @@ void CEXIMemoryCard::setupGciFolder(u16 sizeMb)
CountryCode, CurrentGameId);
}
void CEXIMemoryCard::setupRawMemcard(u16 sizeMb)
void CEXIMemoryCard::SetupRawMemcard(u16 sizeMb)
{
std::string filename =
(card_index == 0) ? SConfig::GetInstance().m_strMemoryCardA : SConfig::GetInstance().m_strMemoryCardB;
@ -208,7 +208,7 @@ void CEXIMemoryCard::CmdDoneLater(u64 cycles)
void CEXIMemoryCard::SetCS(int cs)
{
// So that memory card won't be invalidated during flushing
memorycard->joinThread();
memorycard->JoinThread();
if (cs) // not-selected to selected
{
@ -432,7 +432,7 @@ void CEXIMemoryCard::PauseAndLock(bool doLock, bool unpauseOnUnlock)
{
// we don't exactly have anything to pause,
// but let's make sure the flush thread isn't running.
memorycard->joinThread();
memorycard->JoinThread();
}
}

View File

@ -21,8 +21,8 @@ public:
void DMAWrite(u32 _uAddr, u32 _uSize) override;
private:
void setupGciFolder(u16 sizeMb);
void setupRawMemcard(u16 sizeMb);
void SetupGciFolder(u16 sizeMb);
void SetupRawMemcard(u16 sizeMb);
// This is scheduled whenever a page write is issued. The this pointer is passed
// through the userdata parameter, so that it can then call Flush on the right card.
static void FlushCallback(u64 userdata, int cyclesLate);

View File

@ -188,10 +188,10 @@ GCMemcard::GCMemcard(const std::string &filename, bool forceCreation, bool ascii
mcdFile.Close();
initDirBatPointers();
InitDirBatPointers();
}
void GCMemcard::initDirBatPointers()
void GCMemcard::InitDirBatPointers()
{
if (BE16(dir.UpdateCounter) > (BE16(dir_backup.UpdateCounter)))
{
@ -1237,7 +1237,7 @@ bool GCMemcard::Format(bool ascii, u16 SizeMb)
mc_data_blocks.clear();
mc_data_blocks.resize(maxBlock - MC_FST_BLOCKS);
initDirBatPointers();
InitDirBatPointers();
m_valid = true;
return Save();

View File

@ -76,7 +76,7 @@ public:
virtual void ClearBlock(u32 address) = 0;
virtual void ClearAll() = 0;
virtual void DoState(PointerWrap &p) = 0;
virtual void joinThread() {};
virtual void JoinThread() {};
u32 GetCardId() { return nintendo_card_id; }
protected:
@ -87,8 +87,16 @@ protected:
struct GCMBlock
{
GCMBlock() { erase(); }
void erase() { memset(block, 0xFF, BLOCK_SIZE); }
GCMBlock()
{
Erase();
}
void Erase()
{
memset(block, 0xFF, BLOCK_SIZE);
}
u8 block[BLOCK_SIZE];
};
@ -325,7 +333,7 @@ private:
std::vector<GCMBlock> mc_data_blocks;
u32 ImportGciInternal(FILE* gcih, const std::string& inputFile, const std::string &outputFile);
void initDirBatPointers();
void InitDirBatPointers();
public:

View File

@ -316,7 +316,7 @@ void GCMemcardDirectory::ClearBlock(u32 address)
if (m_LastBlock == -1)
return;
}
((GCMBlock *)m_LastBlockAddress)->erase();
((GCMBlock *)m_LastBlockAddress)->Erase();
}
inline void GCMemcardDirectory::SyncSaves()

View File

@ -75,7 +75,7 @@ MemoryCard::~MemoryCard()
delete[] memory_card_content;
}
void MemoryCard::joinThread()
void MemoryCard::JoinThread()
{
if (flushThread.joinable())
{

View File

@ -29,7 +29,7 @@ public:
void ClearBlock(u32 address) override;
void ClearAll() override;
void DoState(PointerWrap &p) override;
void joinThread() override;
void JoinThread() override;
private:
u8 *memory_card_content;

View File

@ -25,35 +25,35 @@ public:
m_last_start = 0;
}
void start(int node)
void Start(int node)
{
m_last_start = m_ptr;
unsigned char hdr[3] = {0xe0, (unsigned char)node, 0};
m_csum = 0;
addData(hdr, 3, 1);
AddData(hdr, 3, 1);
}
void addData(const void *data, size_t len)
void AddData(const void *data, size_t len)
{
addData((const unsigned char*)data, len);
AddData((const unsigned char*)data, len);
}
void addData(const char *data)
void AddData(const char *data)
{
addData(data, strlen(data));
AddData(data, strlen(data));
}
void addData(int n)
void AddData(int n)
{
unsigned char cs = n;
addData(&cs, 1);
AddData(&cs, 1);
}
void end()
void End()
{
int len = m_ptr - m_last_start;
m_msg[m_last_start + 2] = len - 2; // assuming len <0xD0
addData(m_csum + len - 2);
AddData(m_csum + len - 2);
}
void addData(const unsigned char *dst, size_t len, int sync = 0)
void AddData(const unsigned char *dst, size_t len, int sync = 0)
{
while (len--)
{
@ -236,8 +236,8 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
int pptr = 2;
JVSIOMessage msg;
msg.start(0);
msg.addData(1);
msg.Start(0);
msg.AddData(1);
unsigned char jvs_io_buffer[0x80];
int nr_bytes = ptr(pptr + 2); // byte after e0 xx
@ -257,46 +257,46 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
switch (cmd)
{
case 0x10: // get ID
msg.addData(1);
msg.AddData(1);
{
char buffer[12];
sprintf(buffer, "JVS-node %02x", node);
//msg.addData(buffer);
msg.addData("JAMMA I/O CONTROLLER");
msg.AddData("JAMMA I/O CONTROLLER");
}
msg.addData(0);
msg.AddData(0);
break;
case 0x11: // cmd revision
msg.addData(1);
msg.addData(0x11);
msg.AddData(1);
msg.AddData(0x11);
break;
case 0x12: // jvs revision
msg.addData(1);
msg.addData(0x12);
msg.AddData(1);
msg.AddData(0x12);
break;
case 0x13: // com revision
msg.addData(1);
msg.addData(0x13);
msg.AddData(1);
msg.AddData(0x13);
break;
case 0x14: // get features
msg.addData(1);
msg.addData((void *)"\x01\x02\x0a\x00", 4); // 2 player, 10 bit
msg.addData((void *)"\x02\x02\x00\x00", 4); // 2 coin slots
msg.AddData(1);
msg.AddData((void *)"\x01\x02\x0a\x00", 4); // 2 player, 10 bit
msg.AddData((void *)"\x02\x02\x00\x00", 4); // 2 coin slots
//msg.addData((void *)"\x03\x02\x08\x00", 4);
msg.addData((void *)"\x00\x00\x00\x00", 4);
msg.AddData((void *)"\x00\x00\x00\x00", 4);
break;
case 0x15:
while (*jvs_io++) {};
msg.addData(1);
msg.AddData(1);
break;
case 0x20:
{
int nr_players = *jvs_io++;
int bytes_per_player = *jvs_io++; /* ??? */
int j;
msg.addData(1);
msg.AddData(1);
msg.addData(0); // tilt
msg.AddData(0); // tilt
for (i=0; i<nr_players; ++i)
{
GCPadStatus PadStatus;
@ -328,20 +328,20 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
player_data[1] |= 0x10;
for (j=0; j<bytes_per_player; ++j)
msg.addData(player_data[j&1]);
msg.AddData(player_data[j&1]);
}
break;
}
case 0x21: // coin
{
int slots = *jvs_io++;
msg.addData(1);
msg.AddData(1);
GCPadStatus PadStatus;
Pad::GetStatus(0, &PadStatus);
while (slots--)
{
msg.addData(0);
msg.addData((PadStatus.button & PAD_BUTTON_START) ? 1 : 0);
msg.AddData(0);
msg.AddData((PadStatus.button & PAD_BUTTON_START) ? 1 : 0);
}
break;
}
@ -352,14 +352,14 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
case 0xf0:
if (*jvs_io++ == 0xD9)
ERROR_LOG(AMBASEBOARDDEBUG, "JVS RESET");
msg.addData(1);
msg.AddData(1);
d10_1 |= 1;
break;
case 0xf1:
node = *jvs_io++;
ERROR_LOG(AMBASEBOARDDEBUG, "JVS SET ADDRESS, node=%d", node);
msg.addData(node == 1);
msg.AddData(node == 1);
break;
default:
break;
@ -369,7 +369,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
}
msg.end();
msg.End();
res[resp++] = ptr(0);

View File

@ -57,7 +57,7 @@ SRAM sram_dump_german = {{
}};
#endif
void initSRAM()
void InitSRAM()
{
File::IOFile file(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strSRAM, "rb");
if (file)

View File

@ -63,7 +63,7 @@ union SRAM
};
};
#pragma pack(pop)
void initSRAM();
void InitSRAM();
void SetCardFlashID(u8* buffer, u8 card_index);
extern SRAM sram_dump;

View File

@ -174,7 +174,7 @@ void Spy(Wiimote* wm_, const void* data_, size_t size_)
// save key
if (region_offset >= 0x40 && region_offset <= 0x4c) {
if (!emu)
wiimote_gen_key(&wm->m_ext_key, wm->m_reg_ext.encryption_key);
WiimoteGenerateKey(&wm->m_ext_key, wm->m_reg_ext.encryption_key);
INFO_LOG(CONSOLE, "Writing key: %s", ArrayToString((u8*)&wm->m_ext_key, sizeof(wm->m_ext_key), 0, 30).c_str());
}
if (data[3] == 0xa4 || data[3] == 0xa6) {
@ -347,7 +347,7 @@ void Spy(Wiimote* wm_, const void* data_, size_t size_)
if (!emu && rdr->address>>8 == 0x40)
{
memcpy(((u8*)&wm->m_reg_ext.encryption_key), rdr->data, rdr->size+1);
wiimote_gen_key(&wm->m_ext_key, wm->m_reg_ext.encryption_key);
WiimoteGenerateKey(&wm->m_ext_key, wm->m_reg_ext.encryption_key);
NOTICE_LOG(CONSOLE, "Reading key: %s", ArrayToString(((u8*)&wm->m_ext_key), sizeof(wm->m_ext_key), 0, 30).c_str());
}
@ -362,7 +362,7 @@ void Spy(Wiimote* wm_, const void* data_, size_t size_)
// SWARN_LOG(CONSOLE, "key %s", ArrayToString(((u8*)&wm->m_ext_key), sizeof(wm->m_ext_key), 0, 30).c_str());
// SWARN_LOG(CONSOLE, "decrypt %s", ArrayToString(rdr->data, rdr->size+1, 0, 30).c_str());
// wiimote_decrypt(&wm->m_ext_key, rdr->data, dataReply[2]&0xffff, rdr->size+1);
// WiimoteDecrypt(&wm->m_ext_key, rdr->data, dataReply[2]&0xffff, rdr->size+1);
// SWARN_LOG(CONSOLE, "decrypt %s", ArrayToString(rdr->data, rdr->size+1, 0, 30).c_str());
// decrypted = true;
//}
@ -394,7 +394,7 @@ void Spy(Wiimote* wm_, const void* data_, size_t size_)
// decrypt
//if(((u8*)&wm->m_reg_ext)[0xf0] == 0xaa) {
// wiimote_decrypt(&wm->m_ext_key, &data[0x07], 0x00, (data[4] >> 0x04) + 1);
// WiimoteDecrypt(&wm->m_ext_key, &data[0x07], 0x00, (data[4] >> 0x04) + 1);
//if (wm->m_extension->name == "NUNCHUCK")
//{
@ -542,9 +542,9 @@ void Spy(Wiimote* wm_, const void* data_, size_t size_)
// decrypt extension data
//if (data[1] == 0x37 && !wm->GetMotionPlusActive())
//if (data[1] == 0x37)
// wiimote_decrypt(&wm->m_ext_key, &data[17], 0x00, 0x06);
// WiimoteDecrypt(&wm->m_ext_key, &data[17], 0x00, 0x06);
//if (data[1] == 0x35)
// wiimote_decrypt(&wm->m_ext_key, &data[7], 0x00, 0x06);
// WiimoteDecrypt(&wm->m_ext_key, &data[7], 0x00, 0x06);
//if (data[1] == 0x35 || data[1] == 0x37)
//{
@ -1004,7 +1004,7 @@ void Wiimote::WriteData(const wm_write_data* const wd)
// Run the key generation on all writes in the key area, it doesn't matter
// that we send it parts of a key, only the last full key will have an effect
if (address >= 0xa40040 && address <= 0xa4004c)
wiimote_gen_key(&m_ext_key, m_reg_ext.encryption_key);
WiimoteGenerateKey(&m_ext_key, m_reg_ext.encryption_key);
}
else if (&m_reg_motion_plus == region_ptr)
{
@ -1139,7 +1139,7 @@ void Wiimote::ReadData(const wm_read_data* const rd)
// Encrypt data read from extension register
// Check if encrypted reads is on
if (0xaa == m_reg_ext.encryption)
wiimote_encrypt(&m_ext_key, block, address & 0xffff, (u8)size);
WiimoteEncrypt(&m_ext_key, block, address & 0xffff, (u8)size);
}
}
break;

View File

@ -186,13 +186,13 @@ static const u8 sboxes[8][256] = {
};
static inline u8 ror8(const u8 a, const u8 b)
static inline u8 ROR8(const u8 a, const u8 b)
{
return (a>>b) | ((a<<(8-b))&0xff);
}
static void genkey(const u8* const rand, const u8 idx, u8* const key)
static void GenerateKey(const u8* const rand, const u8 idx, u8* const key)
{
const u8* const ans = ans_tbl[idx];
u8 t0[10];
@ -200,16 +200,16 @@ static void genkey(const u8* const rand, const u8 idx, u8* const key)
for (int i=0; i<10; ++i)
t0[i] = tsbox[rand[i]];
key[0] = ((ror8((ans[0]^t0[5]),(t0[2]%8)) - t0[9]) ^ t0[4]);
key[1] = ((ror8((ans[1]^t0[1]),(t0[0]%8)) - t0[5]) ^ t0[7]);
key[2] = ((ror8((ans[2]^t0[6]),(t0[8]%8)) - t0[2]) ^ t0[0]);
key[3] = ((ror8((ans[3]^t0[4]),(t0[7]%8)) - t0[3]) ^ t0[2]);
key[4] = ((ror8((ans[4]^t0[1]),(t0[6]%8)) - t0[3]) ^ t0[4]);
key[5] = ((ror8((ans[5]^t0[7]),(t0[8]%8)) - t0[5]) ^ t0[9]);
key[0] = ((ROR8((ans[0]^t0[5]),(t0[2]%8)) - t0[9]) ^ t0[4]);
key[1] = ((ROR8((ans[1]^t0[1]),(t0[0]%8)) - t0[5]) ^ t0[7]);
key[2] = ((ROR8((ans[2]^t0[6]),(t0[8]%8)) - t0[2]) ^ t0[0]);
key[3] = ((ROR8((ans[3]^t0[4]),(t0[7]%8)) - t0[3]) ^ t0[2]);
key[4] = ((ROR8((ans[4]^t0[1]),(t0[6]%8)) - t0[3]) ^ t0[4]);
key[5] = ((ROR8((ans[5]^t0[7]),(t0[8]%8)) - t0[5]) ^ t0[9]);
}
static void gentabs(const u8* const rand, const u8* const key, const u8 idx, u8* const ft, u8* const sb)
static void GenerateTables(const u8* const rand, const u8* const key, const u8 idx, u8* const ft, u8* const sb)
{
ft[0] = sboxes[idx][key[4]] ^ sboxes[(idx+1)%8][rand[3]];
ft[1] = sboxes[idx][key[2]] ^ sboxes[(idx+1)%8][rand[5]];
@ -234,7 +234,7 @@ static void gentabs(const u8* const rand, const u8* const key, const u8 idx, u8*
/* Generate key from the 0x40-0x4c data in g_RegExt */
void wiimote_gen_key(wiimote_key* const key, const u8* const keydata)
void WiimoteGenerateKey(wiimote_key* const key, const u8* const keydata)
{
u8 rand[10];
u8 skey[6];
@ -251,14 +251,14 @@ void wiimote_gen_key(wiimote_key* const key, const u8* const keydata)
for (idx = 0; idx < 7; ++idx)
{
genkey(rand, idx, testkey);
GenerateKey(rand, idx, testkey);
if (0 == memcmp(testkey, skey, 6))
break;
}
// default case is idx = 7 which is valid (homebrew uses it for the 0x17 case)
//DEBUG_LOG(WIIMOTE, "idx: %d", idx);
gentabs(rand, skey, idx, key->ft, key->sb);
GenerateTables(rand, skey, idx, key->ft, key->sb);
//DEBUG_LOG(WIIMOTE, "ft: %02x %02x %02x %02x %02x %02x %02x %02x", key->ft[0], key->ft[1], key->ft[2], key->ft[3], key->ft[4], key->ft[5], key->ft[6], key->ft[7]);
//DEBUG_LOG(WIIMOTE, "sb: %02x %02x %02x %02x %02x %02x %02x %02x", key->sb[0], key->sb[1], key->sb[2], key->sb[3], key->sb[4], key->sb[5], key->sb[6], key->sb[7]);
@ -268,7 +268,7 @@ void wiimote_gen_key(wiimote_key* const key, const u8* const keydata)
// TODO: is there a reason these can only handle a length of 255?
/* Encrypt data */
void wiimote_encrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len)
void WiimoteEncrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len)
{
for (int i = 0; i < len; ++i, ++addr)
data[i] = (data[i] - key->ft[addr % 8]) ^ key->sb[addr % 8];
@ -276,7 +276,7 @@ void wiimote_encrypt(const wiimote_key* const key, u8* const data, int addr, con
/* Decrypt data */
void wiimote_decrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len)
void WiimoteDecrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len)
{
for (int i = 0; i < len; ++i, ++addr)
data[i] = (data[i] ^ key->sb[addr % 8]) + key->ft[addr % 8];

View File

@ -6,9 +6,7 @@
#pragma once
// ===================================================
/* They key structure to use with wiimote_gen_key() */
// ----------------
// The key structure to use with WiimoteGenerateKey()
struct wiimote_key
{
u8 ft[8];
@ -16,7 +14,7 @@ struct wiimote_key
};
void wiimote_encrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len);
void wiimote_decrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len);
void WiimoteEncrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len);
void WiimoteDecrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len);
void wiimote_gen_key(wiimote_key* const key, const u8* const keydata);
void WiimoteGenerateKey(wiimote_key* const key, const u8* const keydata);

View File

@ -602,7 +602,7 @@ void Wiimote::GetExtData(u8* const data)
}
if (0xAA == m_reg_ext.encryption)
wiimote_encrypt(&m_ext_key, data, 0x00, sizeof(wm_extension));
WiimoteEncrypt(&m_ext_key, data, 0x00, sizeof(wm_extension));
}
void Wiimote::Update()