vgbc/cartridge/cartridge.cpp

22 lines
443 B
C++

#include <cartridge/cartridge.h>
#include <cstring>
Cartridge::Cartridge(std::ifstream& file)
{
_size = file.seekg(0, std::ios_base::end).tellg();
file.seekg(0, std::ios_base::beg);
_data = new u8[_size];
file.read(reinterpret_cast<char*>(_data), _size);
std::strncpy(_title, (char*)&_data[TITLE], 16);
_title[16] = '\0';
}
u8 Cartridge::operator[](size_t addr)
{
if(addr >= _size)
return 0xFFu;
return _data[addr];
}