コード例 #1
0
ファイル: mgmain.c プロジェクト: SavourySnaX/Project-Ami
int main(int argc,char **argv)
{
    unsigned char *romPtr;
	int running=1;
	int a;
	
	for (a=0;a<256;a++)
	{
		keyUpArray[a]=1;
	}
       
	// Initialize GLFW 
	glfwInit(); 
	// Open an OpenGL window 
	if( !glfwOpenWindow( AMI_LINE_LENGTH, HEIGHT, 0,0,0,0,0,0, GLFW_WINDOW ) ) 
	{ 
		glfwTerminate(); 
		return 1; 
	} 
	
	glfwSetWindowTitle("MinAmi");
	glfwSetWindowPos(670,700);
	
	setupGL(AMI_LINE_LENGTH,HEIGHT);	
	
    romPtr=load_rom("../../out.rom");
    if (!romPtr)
    {
		romPtr=load_rom("out.rom");
		if (!romPtr)
		{
			printf("[ERR] Failed to load rom image\n");
			glfwTerminate(); 
			return 1; 
		}
    }
	
    CPU_BuildTable();
	
    MEM_Initialise(romPtr);
	
	CST_InitialiseCustom();
	CPR_InitialiseCopper();
	CIA_InitialiseCustom();
	BLT_InitialiseBlitter();
	DSP_InitialiseDisplay();
	DSK_InitialiseDisk();
	SPR_InitialiseSprites();
	KBD_InitialiseKeyboard();
	
    CPU_Reset();

    glfwSetKeyCallback(kbHandler);
    
	while (running)
	{
		KBD_Update();
		SPR_Update();
		DSP_Update();			// Note need to priority order these ultimately
		CST_Update();
		DSK_Update();
		CPR_Update();
		CIA_Update();
		BLT_Update();
		CPU_Step();
		
		if (g_newScreenNotify)
		{
			static int lmx=0,lmy=0;
			int mx,my;
		
			DrawScreen();
			
			glfwSwapBuffers();
			
			g_newScreenNotify=0;

			glfwGetMousePos(&mx,&my);
			
			if ((mx>=1 && mx<=AMI_LINE_LENGTH && my>=1 && my <=HEIGHT) || captureMouse)
			{
				int vertMove = my-lmy;
				int horiMove = mx-lmx;
				int oldMoveX = CST_GETWRDU(CST_JOY0DAT,0x00FF);
				int oldMoveY = CST_GETWRDU(CST_JOY0DAT,0xFF00)>>8;
				if (horiMove>127)
					horiMove=127;
				if (horiMove<-128)
					horiMove=-128;
				if (vertMove>127)
					vertMove=127;
				if (vertMove<-128)
					vertMove=-128;
				oldMoveX+=horiMove;
				oldMoveY+=vertMove;
				
				CST_SETWRD(CST_JOY0DAT,((oldMoveY&0xFF)<<8)|(oldMoveX&0xFF),0xFFFF);
				lmx=mx;
				lmy=my;
				
				if (glfwGetMouseButton(GLFW_MOUSE_BUTTON_LEFT))
				{
					leftMouseUp=0;
				}
				else
				{
					leftMouseUp=1;
				}
				if (glfwGetMouseButton(GLFW_MOUSE_BUTTON_MIDDLE))
				{
					if (captureMouse)
					{
						captureMouse=0;
						glfwEnable(GLFW_MOUSE_CURSOR);
					}
					else
					{
						captureMouse=1;
						glfwDisable(GLFW_MOUSE_CURSOR);
					}
				}
				if (glfwGetMouseButton(GLFW_MOUSE_BUTTON_RIGHT))
				{
					rightMouseUp=0;
				}
				else
				{
					rightMouseUp=1;
				}
			}
		}
		
		// Check if ESC key was pressed or window was closed 
		running = !glfwGetKey( GLFW_KEY_ESC ) && glfwGetWindowParam( GLFW_OPENED ); 
	}
コード例 #2
0
ファイル: Hardware.c プロジェクト: RedRingRico/DCJAM2016
Sint32 HW_Initialise( KMBPPMODE p_BPP, SYE_CBL *p_pCableType,
	PNATIVE_MEMORY_FREESTAT p_pMemoryFreeStat )
{
	KMDISPLAYMODE DisplayMode;

	switch( syCblCheck( ) )
	{
		case SYE_CBL_NTSC:
		{
			DisplayMode = KM_DSPMODE_NTSCNI640x480;

			break;
		}
		case SYE_CBL_PAL:
		{
			if( p_pCableType )
			{
				( *p_pCableType ) = SYE_CBL_PAL;
			}

			DisplayMode = KM_DSPMODE_PALNI640x480EXT;

			break;
		}
		case SYE_CBL_VGA:
		{
			DisplayMode = KM_DSPMODE_VGA;

			break;
		}
		default:
		{
			HW_Reboot( );
		}
	}

	set_imask( 15 );

	/* Initialise the CPU, G1 bus, interrupt controller, cache, and timer */
	syHwInit( );
	MEM_Initialise( p_pMemoryFreeStat );
	syStartGlobalConstructor( );
	kmInitDevice( KM_DREAMCAST );

	/* No antialiasing, dither if 16-BPP is enabled */
	kmSetDisplayMode( DisplayMode, p_BPP, KM_DITHER, KM_AAMODE );
	kmSetWaitVsyncCount( 1 );
	
	/* Initialise the interrupt controller and libraries required for after the
	 * graphics library is initialised */
	syHwInit2( );

	PER_Initialise( );

	/* Start the real-time clock */
	syRtcInit( );

	set_imask( 0 );

	if( FS_Initialise( ) != FS_OK )
	{
		LOG_Debug( "Failed to initialise the file system" );

		return HW_FATALERROR;
	}

	if( syCblCheck( ) == SYE_CBL_PAL )
	{
		kmSetPALEXTCallback( PALExtCallback, NULL );
		kmSetDisplayMode( DisplayMode, p_BPP, KM_DITHER, KM_AAMODE );
	}

	return HW_OK;
}