예제 #1
0
    uint32 S9xReadJoypad (int which1)
    {
        uint32 val=0x80000000;
        if (mInMenu) return val;
        if (which1 != 0) return val;

        u32 joy = sal_InputPoll();

        if (((joy & SAL_INPUT_SELECT) && (joy & SAL_INPUT_START))
                || (joy & SAL_INPUT_MENU))
        {
            mEnterMenu = 1;
            return val;
        }

#if 0
        if ((joy & SAL_INPUT_L)&&(joy & SAL_INPUT_R)&&(joy & SAL_INPUT_UP))
        {
            if(mVolumeTimer==0)
            {
                mMenuOptions.volume++;
                if(mMenuOptions.volume>31) mMenuOptions.volume=31;
                sal_AudioSetVolume(mMenuOptions.volume,mMenuOptions.volume);
                mVolumeTimer=5;
                mVolumeDisplayTimer=60;
                sprintf(mVolumeDisplay,"Vol: %d",mMenuOptions.volume);
            }
            return val;
        }

        if ((joy & SAL_INPUT_L)&&(joy & SAL_INPUT_R)&&(joy & SAL_INPUT_DOWN))
        {
            if(mVolumeTimer==0)
            {
                mMenuOptions.volume--;
                if(mMenuOptions.volume>31) mMenuOptions.volume=0;
                sal_AudioSetVolume(mMenuOptions.volume,mMenuOptions.volume);
                mVolumeTimer=5;
                mVolumeDisplayTimer=60;
                sprintf(mVolumeDisplay,"Vol: %d",mMenuOptions.volume);
            }
            return val;
        }
#endif

        if (joy & SAL_INPUT_Y) val |= SNES_Y_MASK;
        if (joy & SAL_INPUT_A) val |= SNES_A_MASK;
        if (joy & SAL_INPUT_B) val |= SNES_B_MASK;
        if (joy & SAL_INPUT_X) val |= SNES_X_MASK;

        if (joy & SAL_INPUT_UP) 	val |= SNES_UP_MASK;
        if (joy & SAL_INPUT_DOWN) 	val |= SNES_DOWN_MASK;
        if (joy & SAL_INPUT_LEFT) 	val |= SNES_LEFT_MASK;
        if (joy & SAL_INPUT_RIGHT)	val |= SNES_RIGHT_MASK;
        if (joy & SAL_INPUT_START) 	val |= SNES_START_MASK;
        if (joy & SAL_INPUT_SELECT) 	val |= SNES_SELECT_MASK;
        if (joy & SAL_INPUT_L) 		val |= SNES_TL_MASK;
        if (joy & SAL_INPUT_R) 		val |= SNES_TR_MASK;

        return val;
    }
예제 #2
0
int mainEntry(int argc, char* argv[])
{
	int ref = 0;

	s32 event=EVENT_NONE;

	sal_Init();
	sal_VideoInit(16,SAL_RGB(0,0,0),Memory.ROMFramesPerSecond);

	mRomName[0]=0;
	if (argc >= 2) 
 		strcpy(mRomName, argv[1]); // Record ROM name

	MenuInit(sal_DirectoryGetHome(), &mMenuOptions);


	if(SnesInit() == SAL_ERROR)
	{
		sal_Reset();
		return 0;
	}

	while(1)
	{
		mInMenu=1;
		event=MenuRun(mRomName);
		mInMenu=0;

		if(event==EVENT_LOAD_ROM)
		{
			if(mTempState) free(mTempState);
			mTempState=NULL;
			if(SnesRomLoad() == SAL_ERROR) 
			{
				MenuMessageBox("Failed to load rom",mRomName,"Press any button to continue", MENU_MESSAGE_BOX_MODE_PAUSE);
				sal_Reset();
		    		return 0;
			}
			else
			{
				event=EVENT_RUN_ROM;
		  	}
		}

		if(event==EVENT_RESET_ROM)
		{
			S9xReset();
			event=EVENT_RUN_ROM;
		}

		if(event==EVENT_RUN_ROM)
		{
			if(mMenuOptions.fullScreen)
			{
				sal_VideoSetScaling(SNES_WIDTH,SNES_HEIGHT);
			}

			if(mMenuOptions.transparency)	Settings.Transparency = TRUE;
			else Settings.Transparency = FALSE;

			sal_AudioSetVolume(mMenuOptions.volume,mMenuOptions.volume);
			sal_CpuSpeedSet(mMenuOptions.cpuSpeed);	
			sal_VideoClear(0);
			sal_VideoFlip(1);
			sal_VideoClear(0);
			sal_VideoFlip(1);
			if(mMenuOptions.soundEnabled) 	
				RunSound();
			else	RunNoSound();

			event=EVENT_NONE;
		}

		if(event==EVENT_EXIT_APP) break;	
	}

	if(mTempState) free(mTempState);
	mTempState=NULL;
	
	S9xGraphicsDeinit();
	S9xDeinitAPU();
	Memory.Deinit();

	free(GFX.SubZBuffer);
	free(GFX.ZBuffer);
	free(GFX.SubScreen);
	GFX.SubZBuffer=NULL;
	GFX.ZBuffer=NULL;
	GFX.SubScreen=NULL;

	sal_Reset();
  	return 0;
}