Well I have a project of a gameboy emulator for android, I'm writing using the android NDK for the emulation part, and the java for the graphic interface itself.
Well first I started writing a small class to read retrieve the cartridge header information.
When I use:
__android_log_write(ANDROID_LOG_DEBUG, "File name", m_FileName);
std::fstream cartFile(m_FileName, std::ios::in | std::ios::binary);
if(!cartFile.bad()){
std::string content((std::istreambuf_iterator<char>(cartFile)), (std::istreambuf_iterator<char>()));
__android_log_print(ANDROID_LOG_DEBUG, "Cart", "Content: %s", content.c_str());
}
cartFile.close();
The output is simply absolutely nothing.
But when I use getline:
std::string content;
while(!cartFile.eof()){
std::getline(cartFile, content);
__android_log_print(ANDROID_LOG_DEBUG, "Cart", "Content: %s", content.c_str());
}
I have the following output:
Thatis,thefileisreadinastringasitshouldbedone,rightafteritisreadIplantostorethecontentsinanunsignedchararraysothatIcanmanipulatetheromandstartworkingontheheader.
AlltheinformationtowritethisemulatorIamremovingfromthissite: link And from this manual: link
It also guides me through open source gameboy emulators in github.