Example #1
0
void CMempak::WriteTo(int32_t Control, uint32_t address, uint8_t * data)
{
    if (address < 0x8000)
    {
        if (!m_Formatted[Control])
        {
            CMempak::Format(Control);
            m_Formatted[Control] = true;
        }
        if (memcmp(&m_Mempaks[Control][address], data, 0x20) != 0)
        {
            if (!m_MempakHandle[Control].IsOpen())
            {
                LoadMempak(Control, true);
            }
            memcpy(&m_Mempaks[Control][address], data, 0x20);

            m_MempakHandle[Control].Seek(address, CFile::begin);
            m_MempakHandle[Control].Write(data, 0x20);
        }
    }
    else
    {
        /* Rumble pack area */
    }
}
Example #2
0
void CMempak::ReadFrom(int32_t Control, uint32_t address, uint8_t * data)
{
    if (address < 0x8000)
    {
        if (m_SaveExists[Control] && !m_MempakHandle[Control].IsOpen())
        {
            LoadMempak(Control, false);
        }

        memcpy(data, &m_Mempaks[Control][address], 0x20);
    }
    else
    {
        memset(data, 0x00, 0x20);
        /* Rumble pack area */
    }
}
Example #3
0
void Mempak::ReadFrom(int Control, int Address, BYTE * Buffer)
{
	if (Address < 0x8000)
	{
		if (hMempakFile[Control] == NULL)
		{
			LoadMempak(Control);
		}
		memcpy(Buffer, &Mempaks[Control][Address], 0x20);
	}
	else
	{
		memset(Buffer, 0, 0x20);
		/* Rumble pack area */
	}

	Buffer[0x20] = CalculateCrc(Buffer);
}
Example #4
0
void Mempak::ReadFrom(int Control, BYTE * command)
{
	DWORD address = (command[3] << 8) | (command[4] & 0xE0);

	if (address < 0x8000)
	{
		if (hMempakFile[Control] == NULL)
		{
			LoadMempak(Control);
		}
		memcpy(&command[5], &Mempaks[Control][address], 0x20);
	}
	else
	{
		memset(&command[5], 0x00, 0x20);
		/* Rumble pack area */
	}
}
Example #5
0
void WriteToMempak(int Control, int Address, BYTE * Buffer) {
	DWORD dwWritten;
	
	if (Address == 0x8001) { Buffer[0x20] = Mempacks_CalulateCrc(Buffer); return; }

	Address &= 0xFFE0;
	if (Address <= 0x7FE0) {
		if (hMempakFile == NULL) {
			LoadMempak();
		}
		memcpy(&Mempak[Control][Address], Buffer, 0x20);

		SetFilePointer(hMempakFile,Control*0x8000,NULL,FILE_BEGIN);
		WriteFile(hMempakFile,&Mempak[Control][0],0x8000,&dwWritten,NULL);
	} else {
		/* Rumble pack area */
	}
	Buffer[0x20] = Mempacks_CalulateCrc(Buffer);
}
Example #6
0
void ReadFromMempak(int Control, int Address, BYTE * Buffer) {	
	if (Address == 0x8001) {
		memset(Buffer, 0, 0x20);
		Buffer[0x20] = Mempacks_CalulateCrc(Buffer);
		return;
	}
	Address &= 0xFFE0;

	if (Address <= 0x7FE0) {
		if (hMempakFile == NULL) {
			LoadMempak();
		}
		memcpy(Buffer, &Mempak[Control][Address], 0x20);
	} else {
		memset(Buffer, 0, 0x20);
		/* Rumble pack area */
	}

	Buffer[0x20] = Mempacks_CalulateCrc(Buffer);
}
Example #7
0
void Mempak::WriteTo(int Control, int Address, BYTE * Buffer)
{
	DWORD dwWritten;

	if (Address < 0x8000)
	{
		if (hMempakFile[Control] == NULL)
		{
			LoadMempak(Control);
		}
		memcpy(&Mempaks[Control][Address], Buffer, 0x20);

		SetFilePointer(hMempakFile[Control], 0,NULL,FILE_BEGIN);
		WriteFile(hMempakFile[Control], &Mempaks[Control][0], 0x8000, &dwWritten, NULL);
	}
	else
	{
		/* Rumble pack area */
	}
	Buffer[0x20] = CalculateCrc(Buffer);
}
Example #8
0
void Mempak::WriteTo(int Control, BYTE * command)
{
	DWORD dwWritten;
	DWORD address = (command[3] << 8) | (command[4] & 0xE0);

	if (address < 0x8000)
	{
		if (hMempakFile[Control] == NULL)
		{
			LoadMempak(Control);
		}
		memcpy(&Mempaks[Control][address], &command[5], 0x20);

		SetFilePointer(hMempakFile[Control], 0,NULL,FILE_BEGIN);
		WriteFile(hMempakFile[Control], &Mempaks[Control][0], 0x8000, &dwWritten, NULL);
	}
	else
	{
		/* Rumble pack area */
	}
}