load files from command line

This commit is contained in:
2024-04-15 01:22:45 -07:00
parent 68f4420b89
commit ae3034065d
4 changed files with 19 additions and 7 deletions

View File

@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.25)
project(GBpp)
project(GameBoy++)
set(CMAKE_CXX_STANDARD 23)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
add_executable(GBpp src/main.cpp
add_executable(GameBoy++ src/main.cpp
src/gameboy.cpp
src/opcodeResolver.cpp
src/interupts.cpp
@@ -18,4 +18,4 @@ add_executable(GBpp src/main.cpp
src/testing.hpp
src/joypad.cpp
)
target_link_libraries(GBpp ${SDL2_LIBRARIES})
target_link_libraries(GameBoy++ ${SDL2_LIBRARIES})

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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);