diff --git a/Src/Model3/Model3.cpp b/Src/Model3/Model3.cpp index 1007cd7..320e6a9 100644 --- a/Src/Model3/Model3.cpp +++ b/Src/Model3/Model3.cpp @@ -1932,9 +1932,8 @@ void CModel3::RunFrame(void) SyncGPUs(); } - // Render frame if ready to do so - if (gpusReady) - RenderFrame(); + // Render frame + RenderFrame(); // Enter notify wait critical section if (!notifyLock->Lock()) @@ -2060,12 +2059,18 @@ void CModel3::RenderFrame(void) { UINT32 start = CThread::GetTicks(); - // Render frame - TileGen.BeginFrame(); - GPU.BeginFrame(); - GPU.RenderFrame(); - GPU.EndFrame(); - TileGen.EndFrame(); + // Call OSD video callbacks + if (BeginFrameVideo() && gpusReady) + { + // Render frame + TileGen.BeginFrame(); + GPU.BeginFrame(); + GPU.RenderFrame(); + GPU.EndFrame(); + TileGen.EndFrame(); + } + + EndFrameVideo(); renderTicks = CThread::GetTicks() - start; } diff --git a/Src/OSD/SDL/Main.cpp b/Src/OSD/SDL/Main.cpp index 3800157..b72c0e5 100644 --- a/Src/OSD/SDL/Main.cpp +++ b/Src/OSD/SDL/Main.cpp @@ -320,7 +320,6 @@ static void PrintGLInfo(bool createScreen, bool infoLog, bool printExtensions) else printf("\n"); } - /****************************************************************************** Configuration @@ -718,6 +717,29 @@ static void UpdateCrosshairs(CInputs *Inputs, unsigned showCrosshairs) glEnd(); } + +/****************************************************************************** + Video Callbacks +******************************************************************************/ + +static CInputs *videoInputs = NULL; +static unsigned videoShowCrosshairs = 0; // bit 1: player 1 crosshair, bit 0: player 2 + +bool BeginFrameVideo() +{ + return true; +} + +void EndFrameVideo() +{ + // Show crosshairs for light gun games + if (videoInputs) + UpdateCrosshairs(videoInputs, videoShowCrosshairs); + + // Swap the buffers + SDL_GL_SwapBuffers(); +} + /****************************************************************************** Main Program Loop @@ -737,7 +759,6 @@ int Supermodel(const char *zipFile, CInputs *Inputs, CINIFile *CmdLine) CRender3D *Render3D = new CRender3D(); unsigned prevFPSTicks, currentFPSTicks, currentTicks, targetTicks, startTicks; unsigned fpsFramesElapsed, framesElapsed; - unsigned showCrosshairs = 0; // bit 1: player 1 crosshair, bit 0: player 2 bool gameHasLightguns = false; bool quit = false; bool paused = false; @@ -774,8 +795,14 @@ int Supermodel(const char *zipFile, CInputs *Inputs, CINIFile *CmdLine) // Hide mouse if fullscreen, enable crosshairs for gun games Inputs->GetInputSystem()->SetMouseVisibility(!g_Config.fullScreen); gameHasLightguns = !!(Model3->GetGameInfo()->inputFlags & (GAME_INPUT_GUN1|GAME_INPUT_GUN2)); - if (g_Config.fullScreen && gameHasLightguns) - showCrosshairs = 1; // show player 1 cursor only by default (TODO: add an IsMapped() member to CInput to allow testing for both lightguns) + if (gameHasLightguns) + { + videoInputs = Inputs; + if (g_Config.fullScreen && gameHasLightguns) + videoShowCrosshairs = 1; // show player 1 cursor only by default (TODO: add an IsMapped() member to CInput to allow testing for both lightguns) + } + else + videoInputs = NULL; // Attach the inputs to the emulator Model3->AttachInputs(Inputs); @@ -812,12 +839,6 @@ int Supermodel(const char *zipFile, CInputs *Inputs, CINIFile *CmdLine) { // If not, run one frame Model3->RunFrame(); - - // Show crosshairs for light gun games - UpdateCrosshairs(Inputs, showCrosshairs); - - // Swap the buffers - SDL_GL_SwapBuffers(); } // Poll the inputs @@ -1016,8 +1037,8 @@ int Supermodel(const char *zipFile, CInputs *Inputs, CINIFile *CmdLine) } else if (Inputs->uiSelectCrosshairs->Pressed() && gameHasLightguns) { - showCrosshairs++; - switch ((showCrosshairs&3)) + videoShowCrosshairs++; + switch ((videoShowCrosshairs&3)) { case 0: puts("Crosshairs disabled."); break; case 3: puts("Crosshairs enabled."); break; diff --git a/Src/OSD/Video.h b/Src/OSD/Video.h new file mode 100755 index 0000000..da5eba8 --- /dev/null +++ b/Src/OSD/Video.h @@ -0,0 +1,47 @@ +/** + ** Supermodel + ** A Sega Model 3 Arcade Emulator. + ** Copyright 2011 Bart Trzynadlowski, Nik Henson + ** + ** This file is part of Supermodel. + ** + ** Supermodel is free software: you can redistribute it and/or modify it under + ** the terms of the GNU General Public License as published by the Free + ** Software Foundation, either version 3 of the License, or (at your option) + ** any later version. + ** + ** Supermodel is distributed in the hope that it will be useful, but WITHOUT + ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + ** more details. + ** + ** You should have received a copy of the GNU General Public License along + ** with Supermodel. If not, see . + **/ + +/* + * Video.h + * + * Header file for OS-dependent video functionality. + */ + +#ifndef INCLUDED_VIDEO_H +#define INCLUDED_VIDEO_H + +/* + * BeginFrameVideo() + * + * Called at beginning of rendering of video frame. Can be used by OSD layer to prevent rendering to screen. + * + * Returns true if emulator should render frame to screen. + */ +extern bool BeginFrameVideo(); + +/* + * EndFrameVideo() + * + * Called at end of rendering of video frame. Can be used by OSD layer to overlay graphics on screen. + */ +extern void EndFrameVideo(); + +#endif // INCLUDED_VIDEO_H diff --git a/Src/Supermodel.h b/Src/Supermodel.h index 0e37ef9..add3e3a 100644 --- a/Src/Supermodel.h +++ b/Src/Supermodel.h @@ -103,6 +103,7 @@ // OSD Interfaces #include "OSD/Thread.h" #include "OSD/Audio.h" +#include "OSD/Video.h" /****************************************************************************** diff --git a/VS2008/Supermodel.vcproj b/VS2008/Supermodel.vcproj index 1501cd1..f3bb427 100755 --- a/VS2008/Supermodel.vcproj +++ b/VS2008/Supermodel.vcproj @@ -1892,6 +1892,10 @@ RelativePath="..\Src\OSD\Thread.h" > + +