Created
December 22, 2018 02:29
-
-
Save shonumi/200f22309e77ec75e4489d2bbf713ce6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fstream> | |
#include <vector> | |
#include <iostream> | |
#include "common.h" | |
int main() | |
{ | |
std::ifstream in_file("sav.bin", std::ios::binary); | |
if(!in_file.is_open()) | |
{ | |
std::cout<<"Data could not be read. Check file path or permissions. \n"; | |
return false; | |
} | |
std::vector<u16> out_data; | |
//Get file size | |
in_file.seekg(0, in_file.end); | |
u32 in_file_size = in_file.tellg(); | |
in_file.seekg(0, in_file.beg); | |
in_file_size >>= 1; | |
out_data.clear(); | |
u16 temp_word = 0; | |
for(u32 x = 0; x < in_file_size; x++) | |
{ | |
in_file.read((char*)&temp_word, 2); | |
u16 flip = (temp_word >> 8); | |
flip |= ((temp_word & 0xFF) << 8); | |
temp_word = flip; | |
if(x == 0) { temp_word = 56 + (52 * (temp_word - 1)); } | |
else if(x & 0x1) { temp_word = 92 + (52 * (temp_word - 1)); } | |
else { temp_word = 104 + (52 * (temp_word - 1)); } | |
out_data.push_back(temp_word); | |
} | |
in_file.close(); | |
//Save file | |
std::ofstream out_file("pocket_pikachu_db.bin", std::ios::binary); | |
for(u32 x = 0; x < out_data.size(); x++) | |
{ | |
temp_word = out_data[x]; | |
out_file.write((char*)&temp_word, 2); | |
} | |
out_file.close(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't lose this