Esempio n. 1
0
// --------------
// I_FinishUpdate
// --------------
void I_FinishUpdate(void)
{
    if (rendermode == render_none)
        return;

    if (I_SkipFrame())
        return;

    // display a graph of ticrate
    if (cv_ticrate.value)
        displayticrate(cv_ticrate.value);

    //
    if (bDIBMode)
    {
        // paranoia
        if (!hDCMain || !bmiMain || !vid.buffer)
            return;
        // main game loop, still in a window (-win parm)
        SetDIBitsToDevice(hDCMain, 0, 0, vid.width, vid.height, 0, 0, 0, vid.height, vid.buffer, bmiMain,
                          DIB_RGB_COLORS);
    }
    else
#ifdef HWRENDER
        if (rendermode != render_soft)
            HWD.pfnFinishUpdate(cv_vidwait.value);
        else
#endif
        {
            // DIRECT DRAW
            // copy virtual screen to real screen
            // can fail when not active (alt-tab)
            if (LockScreen())
            {
                /// \todo use directX blit here!!? a blit might use hardware with access
                /// to main memory on recent hardware, and software blit of directX may be
                /// optimized for p2 or mmx??
                if (ScreenHeight > vid.height)
                {
                    UINT8 *ptr = (UINT8 *)ScreenPtr;
                    size_t half_excess = ScreenPitch*(ScreenHeight-vid.height)/2;
                    memset(ptr, 0x1F, half_excess);
                    ptr += half_excess;
                    VID_BlitLinearScreen(screens[0], ptr, vid.width*vid.bpp, vid.height,
                                         vid.width*vid.bpp, ScreenPitch);
                    ptr += vid.height*ScreenPitch;
                    memset(ptr, 0x1F, half_excess);
                }
                else
                    VID_BlitLinearScreen(screens[0], (UINT8 *)ScreenPtr, vid.width*vid.bpp, vid.height,
                                         vid.width*vid.bpp, ScreenPitch);

                UnlockScreen();

                // swap screens
                ScreenFlip(cv_vidwait.value);
            }
        }
}
Esempio n. 2
0
float RenderFrame (SystemState *RFState)
{
	static unsigned short FrameCounter=0;

//********************************Start of frame Render*****************************************************
	SetBlinkState(BlinkPhase);
	irq_fs(0);				//FS low to High transition start of display Boink needs this

	for (RFState->LineCounter=0;RFState->LineCounter<13;RFState->LineCounter++)		//Vertical Blanking 13 H lines 
		CPUCycle();

	for (RFState->LineCounter=0;RFState->LineCounter<4;RFState->LineCounter++)		//4 non-Rendered top Boarder lines
		CPUCycle();

	if (!(FrameCounter % RFState->FrameSkip))
		if (LockScreen(RFState))
			return(0);

	for (RFState->LineCounter=0;RFState->LineCounter<(TopBoarder-4);RFState->LineCounter++) 		
	{
		if (!(FrameCounter % RFState->FrameSkip))
			DrawTopBoarder[RFState->BitDepth](RFState);
		CPUCycle();
	}

	for (RFState->LineCounter=0;RFState->LineCounter<LinesperScreen;RFState->LineCounter++)		//Active Display area		
	{
		CPUCycle();
		if (!(FrameCounter % RFState->FrameSkip))
			UpdateScreen[RFState->BitDepth] (RFState);
	} 
	irq_fs(1);  //End of active display FS goes High to Low
	if (VertInteruptEnabled)
		GimeAssertVertInterupt();	
	for (RFState->LineCounter=0;RFState->LineCounter < (BottomBoarder) ;RFState->LineCounter++)	// Bottom boarder 
	{
//		if ( (RFState->LineCounter==1) & (VertInteruptEnabled) )	//Vert Interupt occurs 1 line into 
//			GimeAssertVertInterupt();								// Bottom Boarder MPATDEMO
		CPUCycle();
		if (!(FrameCounter % RFState->FrameSkip))
			DrawBottomBoarder[RFState->BitDepth](RFState);
	}

	if (!(FrameCounter % RFState->FrameSkip))
	{
		UnlockScreen(RFState);
		SetBoarderChange(0);
	}

	for (RFState->LineCounter=0;RFState->LineCounter<6;RFState->LineCounter++)		//Vertical Retrace 6 H lines
		CPUCycle();

	switch (SoundOutputMode)
	{
	case 0:
		FlushAudioBuffer(AudioBuffer,AudioIndex<<2);
		break;
	case 1:
		FlushCassetteBuffer(CassBuffer,AudioIndex);
		break;
	case 2:
		LoadCassetteBuffer(CassBuffer);

		break;
	}
	AudioIndex=0;


/*
	//Debug Code
	Frames++;
	if (Frames==60)
	{
		Frames=0;
		sprintf(Msga,"Total Cycles = %i Scan lines = %i LPS= %i\n",TotalCycles,Scans,LinesperScreen+TopBoarder+BottomBoarder+19);
		WriteLog(Msga,0);
		TotalCycles=0;
		Scans=0;
	}
*/
	return(CalculateFPS());
}
Esempio n. 3
0
void CLCDOutput::OnScreenExpired(CLCDManager* pScreen)
{
    UNREFERENCED_PARAMETER(pScreen);
    UnlockScreen();
}
Esempio n. 4
0
int main(int argc, char **argv)
{
//Initialise SDL
	SDL_Init(SDL_INIT_EVERYTHING);
	
//Setup screen
	SDL_Surface *screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
	
//Load Terrain
	OpenTerrain_Heightmap MyHeightmap;
	MyHeightmap.LoadFromImage("heightmap.png");
	OpenTerrain_DataSource_Heightmap DataSource(&MyHeightmap);
	OpenTerrain_Terrain MyTerrain;
	
	MyTerrain.SetupValues.ChunkSize = 32;
	MyTerrain.SetupValues.ChunksX = 8;
	MyTerrain.SetupValues.ChunksY = 8;
	MyTerrain.SetupValues.LODLevelCount = 1;
	MyTerrain.Setup(&DataSource, 0);
	
//Lock Screen
	LockScreen(screen);
	
//Draw terrain
	unsigned int ChunkVerticesAccross = MyTerrain.ChunkSize + 1;
	for(unsigned int Chunk = 0; Chunk < MyTerrain.LODLevels[0].ChunkCount; Chunk++) {
	//Get chunk
		OpenTerrain_Chunk* ChunkPtr = &MyTerrain.LODLevels[0].Chunks[Chunk];
		
	//Calculate chunk position on screen
		unsigned int ChunkX = ChunkPtr->PosX * ChunkVerticesAccross;
		unsigned int ChunkY = ChunkPtr->PosY * ChunkVerticesAccross;
		
	//Loop through vertices
		for(unsigned int Y = 0; Y < ChunkVerticesAccross; Y++) {
			for(unsigned int X = 0; X < ChunkVerticesAccross; X++) {
			//Get luminance and draw pixel
				unsigned char Luminance = ChunkPtr->Vertices[Y * ChunkVerticesAccross + X] * 255;
				DrawPixel(screen, ChunkX + X, ChunkY + Y, Luminance, Luminance, Luminance);
			}
		}
	}
	
//Unlock screen and update
	UnlockScreen(screen);
	SDL_UpdateRect(screen, 0, 0, 256, 256);
	
//Event loop
    SDL_Event event;
	while(true) {
		while ( SDL_PollEvent(&event) ) {
			switch (event.type) {
				case SDL_QUIT:
					exit(0);
				break;
			}
		}
	}
	
//Return 0
	return 0;
}