Пример #1
0
// Possible return values :
// 0 : execution OK
// 1 : Error loading SDL
// 2 : Error loading rom file
int main(int argc, char* argv[]) {
    log::add_file_log("chip8.log");
    log::core::get()->set_filter(log::trivial::severity >= log::trivial::info);
    BOOST_LOG_TRIVIAL(info) << "Logging modules initialized, launching chip8++!";

    cout << "Starting Chip8_PROGRAM_NAME v"  << Chip8_VERSION_MAJOR << '.' << Chip8_VERSION_MINOR << endl;
    Chip8* context;
    try {
        Chip8Config* cfg = Chip8Config::parseCommandLineAndCfg(argc, argv);
        if(!cfg || !cfg->run())
            return 0;
        context = new Chip8(cfg);
        BOOST_LOG_TRIVIAL(info) << "Chip8 emulator initialized successfully!";

        context->run();

        delete context;
    } catch(Chip8InitError const& e) {
        cerr << "Error initializing Chip8_PROGRAM_NAME." << endl;
        BOOST_LOG_TRIVIAL(fatal) << e.what();
        return 1;
    } catch(std::exception e) {
        cerr << "An unknown exception occured, see log file for details." << endl;
        BOOST_LOG_TRIVIAL(fatal) << e.what();
        throw;
    } catch(...) {
        cerr << "An unknown exception occured." << endl;
        BOOST_LOG_TRIVIAL(fatal) << "Unexpected exception.";
        throw;
    }
    return 0;
}
Пример #2
0
void run()
{
  chip8.run();
}