Fixed screen update when running at full-speed

. Specifically IBIZA.DSK demo which streams data from the disk throughout (ie. so runs at full-speed all the time)
. Update the screen every frame, but only if video memory has changed (check AZTEC.DSK loading time)
. NB. When running at full-speed, then 6502 emulation doesn't do cycle-accurate video updates
Fixed crash that could occur when switch video mode (F9) when running at full-speed
. Occured when g_nVideoClockVert was >= 192
This commit is contained in:
tomcw 2016-07-23 22:53:29 +01:00
parent 66e468db65
commit 02b0d7419a
6 changed files with 82 additions and 7 deletions

View File

@ -79,6 +79,7 @@ TCHAR g_sDebugDir [MAX_PATH] = TEXT(""); // TODO: Not currently used
TCHAR g_sScreenShotDir[MAX_PATH] = TEXT(""); // TODO: Not currently used
TCHAR g_sCurrentDir[MAX_PATH] = TEXT(""); // Also Starting Dir. Debugger uses this when load/save
BOOL restart = 0;
bool g_bRestartFullScreen = false;
DWORD g_dwSpeed = SPEED_NORMAL; // Affected by Config dialog's speed slider bar
double g_fCurrentCLK6502 = CLK_6502; // Affected by Config dialog's speed slider bar
@ -215,7 +216,10 @@ void ContinueExecution(void)
else
{
if (bWasFullSpeed)
{
VideoRedrawScreenDuringFullSpeed(0, true); // Invalidate the copies of video memory
VideoRedrawScreenAfterFullSpeed(g_dwCyclesThisFrame);
}
// Don't call Spkr_Demute()
MB_Demute();
@ -247,6 +251,12 @@ void ContinueExecution(void)
{
g_dwCyclesThisFrame -= dwClksPerFrame;
if (g_bFullSpeed)
{
// For IBIZA.DSK
VideoRedrawScreenDuringFullSpeed(g_dwCyclesThisFrame);
}
VideoRefreshScreen(0); // Just copy the output of our Apple framebuffer to the system Back Buffer
MB_EndOfVideoFrame();
}
@ -1146,6 +1156,12 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
EnterMessageLoop();
LogFileOutput("Main: LeaveMessageLoop()\n");
if (restart)
{
bSetFullScreen = g_bRestartFullScreen;
g_bRestartFullScreen = false;
}
MB_Reset();
LogFileOutput("Main: MB_Reset()\n");

View File

@ -31,6 +31,7 @@ extern TCHAR g_sProgramDir[MAX_PATH];
extern TCHAR g_sCurrentDir[MAX_PATH];
extern BOOL restart;
extern bool g_bRestartFullScreen;
extern DWORD g_dwSpeed;
extern double g_fCurrentCLK6502;

View File

@ -978,6 +978,8 @@ LRESULT CALLBACK FrameWndProc (
case WM_CLOSE:
LogFileOutput("WM_CLOSE\n");
if (g_bIsFullScreen && restart)
g_bRestartFullScreen = true;
if (g_bIsFullScreen)
SetNormalMode();
if (!IsIconic(window))
@ -1224,10 +1226,9 @@ LRESULT CALLBACK FrameWndProc (
DrawStatusArea( (HDC)0, DRAW_TITLE );
VideoReinitialize();
if ((g_nAppMode != MODE_LOGO) || ((g_nAppMode == MODE_DEBUG) && (g_bDebuggerViewingAppleOutput)))
if (g_nAppMode != MODE_LOGO)
{
//VideoRedrawScreen();
VideoRefreshScreen( g_bDebuggerViewingAppleOutput );
VideoRefreshScreen( g_nAppMode == MODE_DEBUG ? g_bDebuggerViewingAppleOutput : 0);
}
Config_Save_Video();

View File

@ -121,10 +121,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define VIDEO_SCANNER_Y_MIXED 160 // num scanlins for mixed graphics + text
#define VIDEO_SCANNER_Y_DISPLAY 192 // max displayable scanlines
uint16_t g_aHorzClockMemAddress[VIDEO_SCANNER_MAX_HORZ];
static uint16_t g_aHorzClockMemAddress[VIDEO_SCANNER_MAX_HORZ];
bgra_t *g_pVideoAddress = 0;
bgra_t *g_pScanLines[VIDEO_SCANNER_Y_DISPLAY*2]; // To maintain the 280x192 aspect ratio for 560px width, we double every scan line -> 560x384
static bgra_t *g_pVideoAddress = 0;
static bgra_t *g_pScanLines[VIDEO_SCANNER_Y_DISPLAY*2]; // To maintain the 280x192 aspect ratio for 560px width, we double every scan line -> 560x384
static unsigned (*g_pHorzClockOffset)[VIDEO_SCANNER_MAX_HORZ] = 0;
@ -770,7 +770,7 @@ inline void updateVideoScannerHorzEOL()
//===========================================================================
inline void updateVideoScannerAddress()
{
g_pVideoAddress = g_pScanLines[2*g_nVideoClockVert];
g_pVideoAddress = g_nVideoClockVert<VIDEO_SCANNER_Y_DISPLAY ? g_pScanLines[2*g_nVideoClockVert] : g_pScanLines[0];
g_nColorPhaseNTSC = INITIAL_COLOR_PHASE;
g_nLastColumnPixelNTSC = 0;
g_nSignalBitsNTSC = 0;

View File

@ -1094,6 +1094,62 @@ void VideoDisplayLogo ()
//===========================================================================
// AZTEC.DSK: From boot to 'Press any key' (Release build)
// . 66s always update every frame
// . 15s only update if any video memory (main/aux, text/hgr, pages1&2) has changed
// . 10s only update if HIRES changes (17s for Debug build)
// . ~9s no update during full-speed (but IBIZA.DSK doesn't show anything!)
void VideoRedrawScreenDuringFullSpeed(DWORD dwCyclesThisFrame, bool bInvalidate /*=false*/)
{
static bool bValid = false;
static BYTE text_main[1024*2] = {0}; // page1 & 2
static BYTE text_aux[1024*2] = {0}; // page1 & 2
static BYTE hgr_main[8192*2] = {0}; // page1 & 2
static BYTE hgr_aux[8192*2] = {0}; // page1 & 2
if (bInvalidate)
{
bValid = false;
return;
}
bool bRedraw = true; // Always redraw for bValid==false (ie. just entered full-speed mode)
if (bValid)
{
if ((g_uVideoMode&(VF_DHIRES|VF_HIRES|VF_TEXT|VF_MIXED)) == VF_HIRES)
{
// HIRES (not MIXED) - eg. AZTEC.DSK
if ((g_uVideoMode&VF_PAGE2) == 0)
bRedraw = memcmp(&hgr_main[0x0000], MemGetMainPtr(0x2000), 8192) != 0;
else
bRedraw = memcmp(&hgr_main[0x2000], MemGetMainPtr(0x4000), 8192) != 0;
}
else
{
bRedraw =
(memcmp(text_main, MemGetMainPtr(0x400), sizeof(text_main)) != 0) ||
(memcmp(text_aux, MemGetAuxPtr(0x400), sizeof(text_aux)) != 0) ||
(memcmp(hgr_main, MemGetMainPtr(0x2000), sizeof(hgr_main)) != 0) ||
(memcmp(hgr_aux, MemGetAuxPtr(0x2000), sizeof(hgr_aux)) != 0);
}
}
if (bRedraw)
VideoRedrawScreenAfterFullSpeed(dwCyclesThisFrame);
// Copy all video memory (+ screen holes)
memcpy(text_main, MemGetMainPtr(0x400), sizeof(text_main));
memcpy(text_aux, MemGetAuxPtr(0x400), sizeof(text_aux));
memcpy(hgr_main, MemGetMainPtr(0x2000), sizeof(hgr_main));
memcpy(hgr_aux, MemGetAuxPtr(0x2000), sizeof(hgr_aux));
bValid = true;
}
//===========================================================================
void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame)
{
const int nScanLines = bVideoScannerNTSC ? kNTSCScanLines : kPALScanLines;

View File

@ -169,6 +169,7 @@ void VideoDestroy ();
void VideoDisplayLogo ();
void VideoInitialize ();
void VideoRealizePalette (HDC);
void VideoRedrawScreenDuringFullSpeed(DWORD dwCyclesThisFrame, bool bInvalidate = false);
void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame);
void VideoRedrawScreen (UINT uDelayRefresh = 0);
void VideoRefreshScreen (int bVideoFlags, UINT uDelayRefresh =0 );