Esempio n. 1
0
int mhemain(char* romName)
{
	clearScreen();
	console_write(romName,COLOR_GREEN);
	console_write("Loading...",COLOR_GREEN);

    handleInputFile(romName);

	InitInput();

	clearScreen();

    sound_system_init();

	gp_startSound();

    ngpc_run();

	gp_stopSound();

	if (autosave)
		flashShutdown();

	return 0;
}
Esempio n. 2
0
int main(int argc, char **argv)
{
	char romName[150];

#ifdef GIZMONDO
		strcpy(romName, "\\SD Card\\GizRACE\\");
		strcat(romName, argv[1]);
#else
#ifndef TEST_CFC2_ONLY
	if(argc == 1)
	{
		dbg_printf("Defaulting to runme.ngp\n");
		strncpy(romName, "runme.ngp", 50);
		//dbg_printf("Defaulting to runme.ws\n");
		//strncpy(romName, "runme.ws", 50);
	}
	else if(argc != 2)
	{
		fprintf(stderr, "argc != 2\n");
		return -1;
	}
	else
		strncpy(romName, argv[1], 50);

	dbg_printf("romName=%s\n", romName);
#endif
#endif
	// Initialize SDL
#if defined (TARGET_GP2X) || defined (GIZMONDO)
    if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK) < 0)
#else
    if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_TIMER) < 0)
#endif
	{
		fprintf(stderr, "SDL_Init failed!\n");
		return -1;//Log::Instance()->die(1, SV_FATALERROR, "Couldn't initialize SDL: %s\n", SDL_GetError());
	}

#ifdef TARGET_GP2X
	GP2X_JoystickOpen();
#else
#ifdef GIZMONDO
	joystick = SDL_JoystickOpen(0);
#else
    SDL_WM_SetCaption("RACE!", 0);
#endif
#endif

	// Set up quiting so that it automatically runs on exit.
	atexit (SDL_Quit);

//#define DO_HWDBLBUF
#ifdef DO_HWDBLBUF
	screen = SDL_SetVideoMode (SIZEX, SIZEY, 16, SDL_HWSURFACE | SDL_DOUBLEBUF);
#else
	//screen = SDL_SetVideoMode (SIZEX, SIZEY, 8, SDL_SWSURFACE | SDL_HWPALETTE);
	//screen = SDL_SetVideoMode (SIZEX, SIZEY, 16, SDL_SWSURFACE);
#ifdef GIZMONDO
	screen = SDL_SetVideoMode (320, 240, 16, SDL_HWSURFACE | SDL_HWPALETTE | SDL_FULLSCREEN);
#else
	screen = SDL_SetVideoMode (320, 240, 16, SDL_SWSURFACE);
#endif
#endif
	if (screen == NULL)
	{
		fprintf(stderr, "SDL_SetVideoMode failed!\n");
		return -1;
	}
	else
	{
		dbg_print("screen params: bpp=%d\n", screen->format->BitsPerPixel);
	}

	SDL_ShowCursor(0);  //disable the cursor

	/* Set up the SDL_TTF */
	TTF_Init();
	atexit(TTF_Quit);

#if !defined(GIZMONDO) && !defined(TARGET_WIZ)
    SDL_AudioSpec wav,retFmt;
    SDL_Surface *splash = IMG_Load("splash.jpg");
    if(splash)
    {
        SDL_BlitSurface(splash, NULL, screen, NULL);
        SDL_Flip(screen);
    }
    else
    {
        SDL_Surface *splash = IMG_Load("splash.bmp");
        if(splash)
        {
            SDL_BlitSurface(splash, NULL, screen, NULL);
            SDL_Flip(screen);
        }
    }

	InitInput(NULL);

    if(SDL_LoadWAV("intro.wav", &wav, &audio_buf, &audio_len) == NULL)
    {
        printf("Unable to open intro wav!\n");
    }
    else
    {
        wav.callback = introAudioCallback;
        wav.userdata = NULL;
        if ( SDL_OpenAudio(&wav, &retFmt) < 0 ) {
            fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
            exit(1);
        }

        SDL_PauseAudio(0);

        while (played<audio_len)
        {
            UpdateInputState();
            if (ngpInputState & 0x70)
                break;
        }
        while (ngpInputState & 0x70)
        {
            UpdateInputState();
        }
    }

    SDL_PauseAudio(0);

    SDL_CloseAudio();
    SDL_FreeSurface(splash);
    SDL_FreeWAV(audio_buf);

    if(LoadRomFromGP2X(romName, screen) <= 0)
    {
        dbg_print("LoadRomFromPSP failed!\n");
        exit(1);
    }
#else
    InitInput(NULL);

    if(LoadRomFromGP2X(romName, screen) <= 0)
    {
        dbg_print("LoadRomFromPSP failed!\n");
        exit(1);
    }
#endif

	//dbg_print("openNgp(%s)\n", romName);

	//emulate
	//see ngpc.cpp and ngpcDoc.cpp

    //system_sound_init();
    sound_system_init();

    handleInputFile(romName);

#if defined(TARGET_GP2X) && !defined(TARGET_WIZ)
	system("/sbin/rmmod mmuhack");
	system("/sbin/insmod mmuhack.o");

	int mmufd = open("/dev/mmuhack", O_RDWR);
	if(mmufd < 0)
	{
	printf("MMU hack failed\n");
	}
	else
	{
	printf("MMU hack loaded\n");
	close(mmufd);
	}
#endif

	dbg_print("Running NGPC Emulation\n");

    ngpc_run();

	flashShutdown();

#if defined(TARGET_GP2X) && !defined(TARGET_WIZ)
	system("/sbin/rmmod mmuhack");
#endif
	return 0;
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
	char romName[512];

#ifdef TARGET_PSP
    SetupCallbacks();

    scePowerSetClockFrequency(222, 222, 111);
    //scePowerSetClockFrequency(266, 266, 133);
    //scePowerSetClockFrequency(333, 333, 166);
#endif
    if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK) < 0)
	{
		printf("SDL_Init failed!\n");
#ifdef TARGET_PSP
		sceKernelExitGame();
#endif
		return -1;
	}
	// Set up quiting so that it automatically runs on exit.
	atexit(SDL_Quit);

	PSP_JoystickOpen();

	actualScreen = SDL_SetVideoMode (SIZEX, SIZEY, 16, SDL_SWSURFACE);
	if (actualScreen == NULL)
	{
		printf("SDL_SetVideoMode failed!\n");
#ifdef TARGET_PSP
		sceKernelExitGame();
#endif
		return -1;
	}
	else
	{
		dbg_print("screen params: bpp=%d\n", actualScreen->format->BitsPerPixel);
	}
#ifdef ZOOM_SUPPORT
    screen = SDL_CreateRGBSurface (actualScreen->flags,
                                actualScreen->w,
                                actualScreen->h,
                                actualScreen->format->BitsPerPixel,
                                actualScreen->format->Rmask,
                                actualScreen->format->Gmask,
                                actualScreen->format->Bmask,
                                actualScreen->format->Amask);
	if (screen == NULL)
	{
		printf("SDL_CreateRGBSurface failed!\n");
#ifdef TARGET_PSP
		sceKernelExitGame();
#endif
		return -1;
	}
#else
    screen = actualScreen;
#endif
	SDL_ShowCursor(0);  //disable the cursor

	/* Set up the SDL_TTF */
	TTF_Init();
	atexit(TTF_Quit);
    //printTTF("calling LoadRomFromPSP", 10, TEXT_HEIGHT*1, white, 1, actualScreen, 1);

    sound_system_init();
    while(!exitNow)
    {
#ifdef TARGET_WIN
		strncpy(romName, argv[1], 500);
		dbg_print("Starting emulation on file \"%s\"\n");
#endif
        if(LoadRomFromPSP(romName, actualScreen)<=0)
        {
            break;
        }
        SDL_FillRect(actualScreen, NULL, SDL_MapRGB(screen->format,0,0,0));//fill black
        SDL_Flip(actualScreen);

//printTTF(romName, 20, TEXT_HEIGHT*16, white, 1, actualScreen, 1);

        system_sound_chipreset();	//Resets chips

        handleInputFile(romName);

        InitInput(NULL);

        dbg_print("Running NGPC Emulation\n");

        SDL_PauseAudio(0);  //run audio
#ifdef TARGET_PSP
        switch(options[PSP_MHZ_OPTION])
        {
            case PSP_MHZ_222:
                scePowerSetClockFrequency(222, 222, 111);
                break;
            case PSP_MHZ_266:
                scePowerSetClockFrequency(266, 266, 133);
                break;
            default:
            case PSP_MHZ_333:
                scePowerSetClockFrequency(333, 333, 166);
                break;
        }
#endif
        ngpc_run();
#ifdef TARGET_PSP
        scePowerSetClockFrequency(222, 222, 111);
#endif
        SDL_PauseAudio(1);  //pause audio

        flashShutdown();
    }

    //printTTF("EXITING", 10, TEXT_HEIGHT*10, white, 1);
#ifdef TARGET_PSP
    sceKernelExitGame(); //Exit the program when it is done.
#endif
	return 0;
}