<commit_before>#ifdef PKMDS_CMAKE_USED
#include <pkmds/pkmds_gba.h>
#else
#include "../../PKMDS/include/pkmds/pkmds_gba.h"
#endif
void read(const char* file_name, gbasavefile *data)
{
	std::ifstream *in = new std::ifstream(file_name,std::ios::binary);
	in->read(reinterpret_cast<char*>(data), sizeof(gbasavefile));
	in->close();
	delete in;
	in = 0;
}
void sortsavefile(gbasavefile * sav)
{
	sortsaveblocks(&(sav->savefilea));
	sortsaveblocks(&(sav->savefileb));
}
void sortsaveblocks(gbasavehalf * savehalf)
{
	sortblocks(savehalf->blocks);
}
bool compareblocks(gbasaveblock a, gbasaveblock b)
{
	return a.footer.blockid < b.footer.blockid;
}
void sortblocks(std::array<gbasaveblock,14> & theblocks)
{
	std::sort(theblocks.begin(),theblocks.end(),compareblocks);
}
void decryptgbapkm(gbapokemon * pkm)
{
	uint32 key = (pkm->trainerid  ^ pkm->pid);
	uint32 * pkmpnt = new uint32;
	pkmpnt = reinterpret_cast<uint32*>(&(pkm->encrypted));
	for(int i = 0; i < 12; i++)
	{
		pkmpnt[i] = (pkmpnt[i] ^ key);
	}
}
const byte t_shuffle[24][4] = {
	{0,1,2,3}, {0,1,3,2}, {0,2,1,3}, {0,2,3,1},
	{0,3,1,2}, {0,3,2,1}, {1,0,2,3}, {1,0,3,2},
	{1,2,0,3}, {1,2,3,0}, {1,3,0,2}, {1,3,2,0},
	{2,0,1,3}, {2,0,3,1}, {2,1,0,3}, {2,1,3,0},
	{2,3,0,1}, {2,3,1,0}, {3,0,1,2}, {3,0,2,1},
	{3,1,0,2}, {3,1,2,0}, {3,2,0,1}, {3,2,1,0}
};
void shufflegbapkm(gbapokemon * pkm, bool un)
{
	byte * pkmpnt = new byte();
	pkmpnt = reinterpret_cast<byte*>(&(pkm->encrypted));
	byte temp[48];
	//byte mode = (((((uint32*) pkmpnt)[0] >> 0xD) & 0x1F) % 24);
	byte mode = pkm->pid % 24;
	if (un) {
		memcpy(&(temp[t_shuffle[mode][0] * 12]), &pkmpnt[0 * 12], 12);
		memcpy(&(temp[t_shuffle[mode][1] * 12]), &pkmpnt[1 * 12], 12);
		memcpy(&(temp[t_shuffle[mode][2] * 12]), &pkmpnt[2 * 12], 12);
		memcpy(&(temp[t_shuffle[mode][3] * 12]), &pkmpnt[3 * 12], 12);
	} else {
		memcpy(&(temp[0 * 12]), &pkmpnt[t_shuffle[mode][0] * 12], 12);
		memcpy(&(temp[1 * 12]), &pkmpnt[t_shuffle[mode][1] * 12], 12);
		memcpy(&(temp[2 * 12]), &pkmpnt[t_shuffle[mode][2] * 12], 12);
		memcpy(&(temp[3 * 12]), &pkmpnt[t_shuffle[mode][3] * 12], 12);
	}
	memcpy(pkmpnt, &temp, 48);
}
void calcchecksum(gbapokemon * pkm)
{
	uint32 sum = 0;
	uint16 * word = new uint16();
	word = reinterpret_cast<uint16*>(&(pkm->encrypted));
	for(int i = 0; i < 24; i++)
	{
		sum += word[i];
	}
	pkm->checksum = sum;
}
int gbatods[386][2] = {
	{1,1},
	{2,2},
	{3,3},
	{4,4},
	{5,5},
	{6,6},
	{7,7},
	{8,8},
	{9,9},
	{10,10},
	{11,11},
	{12,12},
	{13,13},<commit_msg>Update pkmds_gba.cpp<commit_after>#ifdef PKMDS_CMAKE_USED
#include <pkmds/pkmds_gba.h>
#else
#include "../../PKMDS/include/pkmds/pkmds_gba.h"
#endif
void read(const char* file_name, gbasavefile *data)
{
	std::ifstream *in = new std::ifstream(file_name,std::ios::binary);
	in->read(reinterpret_cast<char*>(data), sizeof(gbasavefile));
	in->close();
	delete in;
	in = 0;
}
void sortsavefile(gbasavefile * sav)
{
	sortsaveblocks(&(sav->savefilea));
	sortsaveblocks(&(sav->savefileb));
}
void sortsaveblocks(gbasavehalf * savehalf)
{
	sortblocks(savehalf->blocks);
}
bool compareblocks(gbasaveblock a, gbasaveblock b)
{
	return a.footer.blockid < b.footer.blockid;
}
void sortblocks(std::array<gbasaveblock,14> & theblocks)
{
	std::sort(theblocks.begin(),theblocks.end(),compareblocks);
}
void decryptgbapkm(pokemon_gen3 * pkm)
{
	uint32 key = (pkm->trainerid  ^ pkm->pid);
	uint32 * pkmpnt = new uint32;
	pkmpnt = reinterpret_cast<uint32*>(&(pkm->encrypted));
	for(int i = 0; i < 12; i++)
	{
		pkmpnt[i] = (pkmpnt[i] ^ key);
	}
}
const byte t_shuffle[24][4] = {
	{0,1,2,3}, {0,1,3,2}, {0,2,1,3}, {0,2,3,1},
	{0,3,1,2}, {0,3,2,1}, {1,0,2,3}, {1,0,3,2},
	{1,2,0,3}, {1,2,3,0}, {1,3,0,2}, {1,3,2,0},
	{2,0,1,3}, {2,0,3,1}, {2,1,0,3}, {2,1,3,0},
	{2,3,0,1}, {2,3,1,0}, {3,0,1,2}, {3,0,2,1},
	{3,1,0,2}, {3,1,2,0}, {3,2,0,1}, {3,2,1,0}
};
void shufflegbapkm(pokemon_gen3 * pkm, bool un)
{
	byte * pkmpnt = new byte();
	pkmpnt = reinterpret_cast<byte*>(&(pkm->encrypted));
	byte temp[48];
	//byte mode = (((((uint32*) pkmpnt)[0] >> 0xD) & 0x1F) % 24);
	byte mode = pkm->pid % 24;
	if (un) {
		memcpy(&(temp[t_shuffle[mode][0] * 12]), &pkmpnt[0 * 12], 12);
		memcpy(&(temp[t_shuffle[mode][1] * 12]), &pkmpnt[1 * 12], 12);
		memcpy(&(temp[t_shuffle[mode][2] * 12]), &pkmpnt[2 * 12], 12);
		memcpy(&(temp[t_shuffle[mode][3] * 12]), &pkmpnt[3 * 12], 12);
	} else {
		memcpy(&(temp[0 * 12]), &pkmpnt[t_shuffle[mode][0] * 12], 12);
		memcpy(&(temp[1 * 12]), &pkmpnt[t_shuffle[mode][1] * 12], 12);
		memcpy(&(temp[2 * 12]), &pkmpnt[t_shuffle[mode][2] * 12], 12);
		memcpy(&(temp[3 * 12]), &pkmpnt[t_shuffle[mode][3] * 12], 12);
	}
	memcpy(pkmpnt, &temp, 48);
}
void calcchecksum(pokemon_gen3 * pkm)
{
	uint32 sum = 0;
	uint16 * word = new uint16();
	word = reinterpret_cast<uint16*>(&(pkm->encrypted));
	for(int i = 0; i < 24; i++)
	{
		sum += word[i];
	}
	pkm->checksum = sum;
}
int gbatods[386][2] = {
	{1,1},
	{2,2},
	{3,3},
	{4,4},
	{5,5},
	{6,6},
	{7,7},
	{8,8},
	{9,9},
	{10,10},
	{11,11},
	{12,12},
	{13,13},
{'fraction_non_alphanumeric': 0.2597793380140421, 'fraction_numerical': 0.09729187562688064, 'mean_word_length': 5.45019404915912, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4847073', 'n_tokens_mistral': 2690, 'n_tokens_neox': 2496, 'n_words': 404}