Simplified and moved main-loop video update logic into Video.cpp.

Removed complex case below for:
. VideoHasRefreshed(), 'anyupdates'
. VideoCheckPage()

Detailed notes below.

---

Video updates in ContinueExecution() loop:

'anyupdates' gets set if there were any page-flip(s) in last ~17030 cycles:
	anyupdates |= VideoHasRefreshed();
ie. VideoRefreshScreen() was called outside of this loop.

If there's been a call to VideoRefreshScreen() outside of this loop,
  and then the video framebuffer gets written to, ie. VideoApparentlyDirty() returns TRUE,
then don't call VideoRefreshScreen() from this loop for 3 frames.
(If a VideoRefreshScreen() is called outside of this loop then restart the 3 frame count.)

So..
 if the game is flipping, the VideoApparentlyDirty() will return FALSE (since game writes to other framebuffer).
 if the game is not flipping, then VideoHasRefreshed() will return FALSE (since no flips occur).

Therefore this complex case above probably only arises at a boundary eg. when the game is transitioning between these 2 modes,
and so if the emulator does the very occasional screen update in this main loop, it is of no consequence.

(I guess this extra logic was to throttle video updates on very old slow machines)

---

VideoCheckPage(BOOL bForce) was called twice in main-loop:

UnexpectedPage if g_bVideoDisplayPage2 != SW_PAGE2

Once each time through the loop (ie. every 1ms), with bForce=0
	if UnexpectedPage && >500ms since last flip then VideoRefreshScreen()

Once each video frame (ie. ~17030 cycles) when not flipping, with bForce=1
	if UnexpectedPage then VideoRefreshScreen()

Basically this was all about supporting FullSpeed mode, and limiting the calls to VideoRefreshScreen().
This commit is contained in:
tomcw
2014-09-13 22:22:27 +01:00
parent d1dddbe813
commit bc45812f4e
5 changed files with 134 additions and 145 deletions

View File

@@ -4711,9 +4711,9 @@ size_t Util_GetTextScreen ( char* &pText_ )
g_nTextScreen = 0;
memset( pBeg, 0, sizeof( g_aTextScreen ) );
int bBank2 = g_bVideoDisplayPage2;
LPBYTE g_pTextBank1 = MemGetAuxPtr (0x400 << (int)bBank2);
LPBYTE g_pTextBank0 = MemGetMainPtr(0x400 << (int)bBank2);
unsigned int uBank2 = VideoGetSWPAGE2() ? 1 : 0;
LPBYTE g_pTextBank1 = MemGetAuxPtr (0x400 << uBank2);
LPBYTE g_pTextBank0 = MemGetMainPtr(0x400 << uBank2);
for( int y = 0; y < 24; y++ )
{
@@ -4724,7 +4724,7 @@ size_t Util_GetTextScreen ( char* &pText_ )
{
char c; // TODO: FormatCharTxtCtrl() ?
if ( g_bVideoMode & VF_80COL )
if ( VideoGetSW80COL() )
{ // AUX
c = g_pTextBank1[ nAddressStart ] & 0x7F;
c = RemapChar(c);
@@ -4792,7 +4792,7 @@ int CmdTextSave (int nArgs)
_tcscpy( g_sMemoryLoadSaveFileName, g_aArgs[ 1 ].sArg );
else
{
if( g_bVideoMode & VF_80COL )
if( VideoGetSW80COL() )
sprintf( g_sMemoryLoadSaveFileName, "AppleWin_Text80.txt" );
else
sprintf( g_sMemoryLoadSaveFileName, "AppleWin_Text40.txt" );
@@ -5997,11 +5997,11 @@ Update_t _ViewOutput( ViewVideoPage_t iPage, VideoUpdateFuncPtr_t pfUpdate );
Update_t _ViewOutput( ViewVideoPage_t iPage, VideoUpdateFuncPtr_t pfUpdate )
{
g_VideoForceFullRedraw = true;
VideoSetForceFullRedraw();
_Video_Dirty();
switch( iPage )
{
case VIEW_PAGE_X: _Video_SetupBanks( g_bVideoDisplayPage2 ); break; // Page Current
case VIEW_PAGE_X: _Video_SetupBanks( VideoGetSWPAGE2() ); break; // Page Current
case VIEW_PAGE_1: _Video_SetupBanks( false ); break; // Page 1
case VIEW_PAGE_2: _Video_SetupBanks( true ); break; // Page 2 !
default: