load files from command line
This commit is contained in:
@@ -16,11 +16,18 @@ void AddressSpace::mapBootrom() {
|
||||
|
||||
void AddressSpace::loadBootrom(const std::string& filename) {
|
||||
std::ifstream file;
|
||||
if (const uintmax_t size = std::filesystem::file_size(filename); size != 256) {
|
||||
file.open(filename, std::ios::binary);
|
||||
|
||||
if (!file.is_open()) {
|
||||
std::cerr << "Bootrom was not found!\nQuitting!\n" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
const uintmax_t size = std::filesystem::file_size(filename);
|
||||
if (size != 256) {
|
||||
std::cerr << "Bootrom was an unexpected size!\nQuitting!\n" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
file.open(filename, std::ios::binary);
|
||||
file.read(reinterpret_cast<char*>(bootrom), BOOTROM_SIZE);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,15 @@ using json = nlohmann::json;
|
||||
void runJSONTests(GameBoy* gb);
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc != 3) {
|
||||
std::cout << "Usage: " << argv[0] << " <bios> <game>" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto* gb = new GameBoy();
|
||||
gb->SDL2setup();
|
||||
//runJSONTests(gb);
|
||||
gb->start("../dmg_boot.bin", "../roms/DrMario.gb");
|
||||
gb->start(argv[1], argv[2]);
|
||||
gb->SDL2destroy();
|
||||
delete gb;
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@ void GameBoy::drawLine() {
|
||||
|
||||
void GameBoy::SDL2setup() {
|
||||
SDL_Init(SDL_INIT_EVERYTHING);
|
||||
screen = SDL_CreateWindow("GBpp",
|
||||
screen = SDL_CreateWindow("GameBoy++",
|
||||
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
RESOLUTION_X, RESOLUTION_Y,
|
||||
0);
|
||||
|
||||
Reference in New Issue
Block a user