Ejemplo n.º 1
0
Archivo: VGA.c Proyecto: skeezix/zikzak
void SetVGAScreenMode175(uint8_t *framebuffer,int pixelsperrow,int pixelclock)
{
    WaitForLastLineIfVGAEnabled();
    InitializePixelDMA(pixelclock,pixelsperrow);
    SetFrameBuffer(framebuffer);
    SetVGAHorizontalSync31kHzActiveHighForDMA(PixelHSyncHandler175);
}
Ejemplo n.º 2
0
Archivo: VGA.c Proyecto: skeezix/zikzak
void SetVGAScreenMode133(uint8_t *framebuffer,int pixelsperrow,int pixelclock)
{
    WaitForLastLineIfVGAEnabled();
    InitializePixelDMA(pixelclock,pixelsperrow);
    SetFrameBuffer(framebuffer);
    VGAThreeLineCounter=0;
    SetVGAHorizontalSync31kHzForDMA(PixelHSyncHandler133);
}
Ejemplo n.º 3
0
    void Graphics::ResetCachedState()
    {
        Program::Clear();

        viewport_ = Recti(0);

        glGetIntegerv(GL_FRAMEBUFFER_BINDING, &systemFbo_); // On IOS default FBO is not zero

        // Set up texture data read/write alignment
        glPixelStorei(GL_PACK_ALIGNMENT, 1);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

        VertexArrayObj::Clear();
        lastMesh_ = nullptr;
        lastProgram_ = nullptr;
        activeMesh_ = nullptr;
        activeWindow_ = nullptr;

        CHECK_GL_STATUS();

        SetClearColor(Color(0, 0, 0, 1));
        SetClearDepth(1);
        SetClearStencil(0);
        SetFrameBuffer(nullptr);
        SetStencilTest(DEFAULT_STENCIL_ENABLE, DEFAULT_STENCIL_WRITEMASK, DEFAULT_STENCIL_SFAIL,
                       DEFAULT_STENCIL_DPFAIL, DEFAULT_STENCIL_DPPASS, DEFAULT_STENCIL_FUNC, DEFAULT_STENCIL_REF, DEFAULT_STENCIL_COMPAREMASK);
        SetScissorTest();

        CHECK_GL_STATUS();

        SetColorMask(DEFAULT_COLOR_MASK);
        SetDepthMask(DEFAULT_DEPTH_MASK);
        SetDepthFunc(DepthFunc::LESS);
        SetStencilMask(DEFAULT_STENCIL_MASK);
        SetBlendModeTest(DEFAULT_BLEND_MODE);
        EnableDepthTest(DEFAULT_DEPTH_TEST_ENABLE);
        EnableCullFace(DEFAULT_CULL_FACE_ENABLE);
        SetCullFace(CullFaceMode::DEFAULT);
        SetFrontFace(FrontFaceMode::DEFAULT);
        CHECK_GL_STATUS();

        UnboundTextures();
        SetVertexArrayObj(nullptr);
        SetVertexBuffer(nullptr);
        SetIndexBuffer(nullptr);
        SetProgram(nullptr);
        SetSlopeScaledBias(0);

        CHECK_GL_STATUS();
    }
Ejemplo n.º 4
0
int main()
{
	InitializeSystem();
	SysTick_Config(HCLKFrequency()/100);
	InitializeLEDs();

	SetLEDs(0x01);

	uint8_t *framebuffer1=(uint8_t *)0x20000000;
	uint8_t *framebuffer2=(uint8_t *)0x20010000;
	SetLEDs(0x03);
	memset(framebuffer1,0,320*200);
	memset(framebuffer2,0,320*200);

	SetLEDs(0x07);

	IntializeVGAScreenMode320x200(framebuffer1);

	#define NumberOfStars 1050
	static struct Star
	{
		int x,y,dx,f;
	} stars[NumberOfStars];

	for(int i=0;i<NumberOfStars;i++)
	{
		stars[i].x=(RandomInteger()%352-16)<<12;
		stars[i].y=RandomInteger()%200;

		int z=sqrti((NumberOfStars-1-i)*NumberOfStars)*1000/NumberOfStars;
		stars[i].dx=6000*1200/(z+200);

		stars[i].f=(6-(z*7)/1000)+(RandomInteger()%6)*7;
	}

	const RLEBitmap *sprites[7*6]={
		&Star1_0,&Star2_0,&Star3_0,&Star4_0,&Star5_0,&Star6_0,&Star7_0,
		&Star1_1,&Star2_1,&Star3_1,&Star4_1,&Star5_1,&Star6_1,&Star7_1,
		&Star1_2,&Star2_2,&Star3_2,&Star4_2,&Star5_2,&Star6_2,&Star7_2,
		&Star1_3,&Star2_3,&Star3_3,&Star4_3,&Star5_3,&Star6_3,&Star7_3,
		&Star1_4,&Star2_4,&Star3_4,&Star4_4,&Star5_4,&Star6_4,&Star7_4,
		&Star1_5,&Star2_5,&Star3_5,&Star4_5,&Star5_5,&Star6_5,&Star7_5,
	};

	Bitmap frame1,frame2;
	InitializeBitmap(&frame1,320,200,320,framebuffer1);
	InitializeBitmap(&frame2,320,200,320,framebuffer2);

	int frame=0;

	while(1)
	{
		WaitVBL();

		Bitmap *currframe;
		if(frame&1) { currframe=&frame2; SetFrameBuffer(framebuffer1); }
		else { currframe=&frame1; SetFrameBuffer(framebuffer2); }

		ClearBitmap(currframe);

		for(int i=0;i<NumberOfStars;i++)
		{
			DrawRLEBitmap(currframe,sprites[stars[i].f],
			(stars[i].x>>12)-16,stars[i].y-16);

			stars[i].x-=stars[i].dx;
			if(stars[i].x<=-16<<12)
			{
				stars[i].x=(320+16)<<12;
				stars[i].y=RandomInteger()%200;
				stars[i].f=(stars[i].f%7)+(RandomInteger()%6)*7;
			}
		}

		frame++;
	}
}
bool RalScreenFlushPart(rect* inBoundary)
{
    SetFrameBuffer(inBoundary);
    return TRUE;
}
bool RalScreenFlush(void)
{
    SetFrameBuffer(NULL);
    return TRUE;
}
Ejemplo n.º 7
0
int main()
{
	RCC_ClocksTypeDef RCC_Clocks;
	RCC_GetClocksFreq(&RCC_Clocks);

	SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);

	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

	InitializeLEDs();
	InitializeUserInterface();
	InitializeRandom();
	InitializeRumble();

	//Clear framebuffers
	memset(ADDR_FRAMEBUFFER1, 0x00, 320*200);
	memset(ADDR_FRAMEBUFFER2, 0x00, 320*200);

	//Create drawing surfaces
	InitializeBitmap(&frame1,320,200,320,ADDR_FRAMEBUFFER1);
	InitializeBitmap(&frame2,320,200,320,ADDR_FRAMEBUFFER2);

	//Switch on VGA
	IntializeVGAScreenMode320x200(ADDR_FRAMEBUFFER1);

	if(!TheGame) {
		EnableDebugOutput(DEBUG_USART);
		fprintf(stderr, "PANIC: Game structure pointer is NULL\r\n");
		return -1;
	}

	if(TheGame->currentState)
		TheGame->currentState->Init(NULL);

	if(!TheGame->currentState->Update || !TheGame->currentState->Draw) {
		fprintf(stderr, "PANIC: Update and/or Draw function pointer is NULL\r\n");
		return -1;
	}

	Gamestate *currentState = TheGame->currentState;

	while(1)
	{
		oldTime = currentTime;
		currentTime = SysTickCounter;
		if (currentState != TheGame->currentState)
		{
			Gamestate *newState = TheGame->currentState;
			if (!newState->initialized) {
				newState->Init(currentState);
				newState->initialized = true;
			}
			if (newState->OnEnter)
				newState->OnEnter(currentState);
			currentState = newState;
		}

		//Swap Buffers
		if(frame&1) { drawingSurface=&frame2; SetFrameBuffer(ADDR_FRAMEBUFFER1); }
		else { drawingSurface=&frame1; SetFrameBuffer(ADDR_FRAMEBUFFER2); }

		//Update and draw
		currentState->Update(currentTime - oldTime);
		currentState->Draw(drawingSurface);

		frame++;

		if (currentState != TheGame->currentState &&
			TheGame->currentState->OnLeave)
		{
			currentState->OnLeave(currentState);
		}
		//VSync
		WaitVBL();
	}
}