Skip to content

Commit

Permalink
Added NFD
Browse files Browse the repository at this point in the history
Added native file dialog to open roms at startup if no command line parameter is provided.
  • Loading branch information
ivodopiviz committed Sep 17, 2017
1 parent 2e0fd72 commit 7607b7d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Chip8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ void Chip8::debugRender()
printf("\n");
}

bool Chip8::loadApplication(const char * filename)
bool Chip8::loadApplication(const char* filename)
{
init();
printf("Loading: %s\n", filename);
Expand Down
17 changes: 13 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@ int display_height = SCREEN_HEIGHT * zoom;

int main(int argc, char* argv[])
{
if (argc < 2)
char* fileName = NULL;

if (argc >= 2)
{
printf("Usage: octo.exe rom\n");
return 1;
fileName = argv[1];
}
else
{
nfdresult_t result = NFD_OpenDialog("c8", NULL, &fileName);
if (result == NFD_CANCEL)
{
return 1;
}
}

// load game
if (!chip8.loadApplication(argv[1]))
if (!chip8.loadApplication(fileName))
return 1;

bool quit = false;
Expand Down

0 comments on commit 7607b7d

Please sign in to comment.