in atari_py/ale_interface/src/emucore/OSystem.cxx [351:440]
bool OSystem::createConsole(const string& romfile)
{
// Do a little error checking; it shouldn't be necessary
if(myConsole) deleteConsole();
bool retval = false;
// If a blank ROM has been given, we reload the current one (assuming one exists)
if(romfile == "")
{
if(myRomFile == "")
{
ale::Logger::Error << "ERROR: Rom file not specified ..." << endl;
return false;
}
}
else
myRomFile = romfile;
// Open the cartridge image and read it in
uInt8* image;
int size = -1;
string md5;
if(openROM(myRomFile, md5, &image, &size))
{
// Get all required info for creating a valid console
Cartridge* cart = (Cartridge*) NULL;
Properties props;
if(queryConsoleInfo(image, size, md5, &cart, props))
{
// Create an instance of the 2600 game console
myConsole = new Console(this, cart, props);
m_colour_palette.loadUserPalette(paletteFile());
#ifdef CHEATCODE_SUPPORT
myCheatManager->loadCheats(md5);
#endif
//ALE myEventHandler->reset(EventHandler::S_EMULATE);
//ALE createFrameBuffer(false); // Takes care of initializeVideo()
//ALE myConsole->initializeAudio();
#ifdef DEBUGGER_SUPPORT
myDebugger->setConsole(myConsole);
myDebugger->initialize();
#endif
if(mySettings->getBool("showinfo"))
cerr << "Game console created:" << endl
<< " ROM file: " << myRomFile << endl
<< myConsole->about() << endl;
else
ale::Logger::Info << "Game console created:" << endl
<< " ROM file: " << myRomFile << endl
<< myConsole->about() << endl;
// Update the timing info for a new console run
resetLoopTiming();
//ALE myFrameBuffer->setCursorState();
retval = true;
}
else
{
ale::Logger::Error << "ERROR: Couldn't create console for " << myRomFile << " ..." << endl;
retval = false;
}
}
else
{
ale::Logger::Error << "ERROR: Couldn't open " << myRomFile << " ..." << endl;
retval = false;
}
// Free the image since we don't need it any longer
if(size != -1) {
delete[] image;
}
if (mySettings->getBool("display_screen", true)) {
#ifndef __USE_SDL
ale::Logger::Error << "Screen display requires directive __USE_SDL to be defined."
<< " Please recompile with flag '-D__USE_SDL'."
<< " See makefile for more information."
<< std::endl;
exit(1);
#endif
p_display_screen = new DisplayScreen(&myConsole->mediaSource(),
mySound, m_colour_palette);
}
return retval;
}