Beispiel #1
0
int main(int argc, char* argv[])
{
	if (SDL_Init(SDL_INIT_EVERYTHING) == -1)
		return 1;

	SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
    SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
    SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
    SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
	SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 );
    SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
	SDL_ShowCursor(SDL_DISABLE);

	screen = SDL_SetVideoMode(160*scale, 144*scale, 32, SDL_SWSURFACE | SDL_OPENGL);// | SDL_FULLSCREEN);
	if (screen == NULL)
		return 1;
	

	SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255));

	SDL_WM_SetCaption("GameYob", NULL);

    mgr_init();

	initInput();
    setMenuDefaults();
    readConfigFile();
    initGFX();

    if (argc >= 2) {
        char* filename = argv[1];
        mgr_loadRom(filename);
    }
    else {
        printf("Give me a gameboy rom pls\n");
        return 1;
    }

    for (;;) {
        mgr_runFrame();
        mgr_updateVBlank();
    }

	return 0;
}
Beispiel #2
0
void initializeGameboy() {
    sgbMode = false;

    switch(gbcModeOption) {
        case 0: // GB
            initGBMode();
            break;
        case 1: // GBC if needed
            if (rom[0][0x143] == 0xC0)
                initGBCMode();
            else
                initGBMode();
            break;
        case 2: // GBC
            if (rom[0][0x143] == 0x80 || rom[0][0x143] == 0xC0)
                initGBCMode();
            else
                initGBMode();
            break;
    }

    bool sgbEnhanced = rom[0][0x14b] == 0x33 && rom[0][0x146] == 0x03;
    if (sgbEnhanced && resultantGBMode != 2 && probingForBorder) {
        resultantGBMode = 2;
        nukeBorder = false;
    }
    else {
        probingForBorder = false;
    }

    initMMU();
    initCPU();
    initLCD();
    initGFX();
    initSND();

    if (!probingForBorder && suspendStateExists) {
        loadState(-1);
        // enter the console on resume
        advanceFrame = true;
    }
    updateScreens();
}
Beispiel #3
0
SDLManager::SDLManager()
{
	initSDL();
	initGFX();
	initInput();
}