diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 6e80f7cd..4348e7e5 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -230,7 +230,7 @@ void ContinueExecution(void) if (g_dwCyclesThisFrame >= dwClksPerFrame) { g_dwCyclesThisFrame -= dwClksPerFrame; - VideoEndOfVideoFrame(); + VideoEndOfVideoFrame(); // NTSC currently requires this ... need to investigate why MB_EndOfVideoFrame(); } diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index cde48207..4a183ceb 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -4215,7 +4215,7 @@ Update_t CmdMemoryLoad (int nArgs) { bBankSpecified = false; } - +// TODO: check if extension ".hgr", ".hgr2", ".dhgr", ".dhgr2" if (g_aArgs[ iArgComma1 ].eToken != TOKEN_COMMA) return Help_Arg_1( CMD_MEMORY_LOAD ); @@ -6031,19 +6031,20 @@ enum ViewVideoPage_t Update_t _ViewOutput( ViewVideoPage_t iPage, VideoUpdateFuncPtr_t pfUpdate ); -Update_t _ViewOutput( ViewVideoPage_t iPage, VideoUpdateFuncPtr_t pfUpdate ) +Update_t _ViewOutput( ViewVideoPage_t iPage, int bVideoModeFlags ) { VideoSetForceFullRedraw(); - _Video_Dirty(); + switch( iPage ) { - 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 ! + case VIEW_PAGE_X: bVideoModeFlags |= _Video_SetupBanks( VideoGetSWPAGE2() ); break; // Page Current + case VIEW_PAGE_1: bVideoModeFlags |= _Video_SetupBanks( false ); break; // Page 1 + case VIEW_PAGE_2: bVideoModeFlags |= _Video_SetupBanks( true ); break; // Page 2 ! default: break; } - _Video_RedrawScreen( pfUpdate ); + + VideoRefreshScreen( bVideoModeFlags ); g_bDebuggerViewingAppleOutput = true; return UPDATE_NOTHING; // intentional } @@ -6051,80 +6052,80 @@ Update_t _ViewOutput( ViewVideoPage_t iPage, VideoUpdateFuncPtr_t pfUpdate ) // Text 40 Update_t CmdViewOutput_Text4X (int nArgs) { - return _ViewOutput( VIEW_PAGE_X, Update40ColCell ); + return _ViewOutput( VIEW_PAGE_X, VF_TEXT ); } Update_t CmdViewOutput_Text41 (int nArgs) { - return _ViewOutput( VIEW_PAGE_1, Update40ColCell ); + return _ViewOutput( VIEW_PAGE_1, VF_TEXT ); } Update_t CmdViewOutput_Text42 (int nArgs) { - return _ViewOutput( VIEW_PAGE_2, Update40ColCell ); + return _ViewOutput( VIEW_PAGE_2, VF_TEXT ); } // Text 80 Update_t CmdViewOutput_Text8X (int nArgs) { - return _ViewOutput( VIEW_PAGE_X, Update80ColCell ); + return _ViewOutput( VIEW_PAGE_X, VF_TEXT | VF_80COL ); } Update_t CmdViewOutput_Text81 (int nArgs) { - return _ViewOutput( VIEW_PAGE_1, Update80ColCell ); + return _ViewOutput( VIEW_PAGE_1, VF_TEXT | VF_80COL ); } Update_t CmdViewOutput_Text82 (int nArgs) { - return _ViewOutput( VIEW_PAGE_2, Update80ColCell ); + return _ViewOutput( VIEW_PAGE_2, VF_TEXT | VF_80COL ); } // Lo-Res Update_t CmdViewOutput_GRX (int nArgs) { - return _ViewOutput( VIEW_PAGE_X, UpdateLoResCell ); + return _ViewOutput( VIEW_PAGE_X, 0 ); } Update_t CmdViewOutput_GR1 (int nArgs) { - return _ViewOutput( VIEW_PAGE_1, UpdateLoResCell ); + return _ViewOutput( VIEW_PAGE_1, 0 ); } Update_t CmdViewOutput_GR2 (int nArgs) { - return _ViewOutput( VIEW_PAGE_2, UpdateLoResCell ); + return _ViewOutput( VIEW_PAGE_2, 0 ); } // Double Lo-Res Update_t CmdViewOutput_DGRX (int nArgs) { - return _ViewOutput( VIEW_PAGE_X, UpdateDLoResCell ); + return _ViewOutput( VIEW_PAGE_X, VF_DHIRES | VF_80COL ); } Update_t CmdViewOutput_DGR1 (int nArgs) { - return _ViewOutput( VIEW_PAGE_1, UpdateDLoResCell ); + return _ViewOutput( VIEW_PAGE_1, VF_DHIRES | VF_80COL ); } Update_t CmdViewOutput_DGR2 (int nArgs) { - return _ViewOutput( VIEW_PAGE_2, UpdateDLoResCell ); + return _ViewOutput( VIEW_PAGE_2, VF_DHIRES | VF_80COL ); } // Hi-Res Update_t CmdViewOutput_HGRX (int nArgs) { - return _ViewOutput( VIEW_PAGE_X, UpdateHiResCell ); + return _ViewOutput( VIEW_PAGE_X, VF_HIRES ); } Update_t CmdViewOutput_HGR1 (int nArgs) { - return _ViewOutput( VIEW_PAGE_1, UpdateHiResCell ); + return _ViewOutput( VIEW_PAGE_1, VF_HIRES ); } Update_t CmdViewOutput_HGR2 (int nArgs) { - return _ViewOutput( VIEW_PAGE_2, UpdateHiResCell ); + return _ViewOutput( VIEW_PAGE_2, VF_HIRES ); } // Double Hi-Res Update_t CmdViewOutput_DHGRX (int nArgs) { - return _ViewOutput( VIEW_PAGE_X, UpdateDHiResCell ); + return _ViewOutput( VIEW_PAGE_X, VF_HIRES | VF_DHIRES ); } Update_t CmdViewOutput_DHGR1 (int nArgs) { - return _ViewOutput( VIEW_PAGE_1, UpdateDHiResCell ); + return _ViewOutput( VIEW_PAGE_1, VF_HIRES | VF_DHIRES ); } Update_t CmdViewOutput_DHGR2 (int nArgs) { - return _ViewOutput( VIEW_PAGE_2, UpdateDHiResCell ); + return _ViewOutput( VIEW_PAGE_2, VF_HIRES | VF_DHIRES ); } // Watches ________________________________________________________________________________________ @@ -7783,8 +7784,8 @@ void DebugContinueStepping () { if (nStepsTaken == 0x10000) // HACK_MAGIC_NUM VideoRedrawScreen(); - else - VideoRefreshScreen(); +// else +// VideoRefreshScreen(); } } else diff --git a/source/Frame.cpp b/source/Frame.cpp index e4960e9b..ad696605 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -564,7 +564,8 @@ static void DrawFrameWindow () DebugDisplay(1); else // Win7: In fullscreen mode with 1 redraw, the the screen doesn't get redraw. - VideoRedrawScreen(g_bIsFullScreen ? 2 : 1); // TC: 22/06/2014: Why 2 redraws in full-screen mode (32-bit only)? (8-bit doesn't need this nor does Win8, just Win7 or older OS's) + //VideoRedrawScreen(g_bIsFullScreen ? 2 : 1); // TC: 22/06/2014: Why 2 redraws in full-screen mode (32-bit only)? (8-bit doesn't need this nor does Win8, just Win7 or older OS's) + VideoRedrawScreen(); // DD Full-Screen Palette: BUGFIX: needs to come _after_ all drawing... if (g_bPaintingWindow) diff --git a/source/Video.cpp b/source/Video.cpp index 7806432c..82a37383 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -2074,7 +2074,7 @@ void VideoBenchmark () { FillMemory(mem+0x400,0x400,0x14); else CopyMemory(mem+0x400,mem+((cycle & 2) ? 0x4000 : 0x6000),0x400); - VideoRefreshScreen(); + VideoRedrawScreen(); // VideoRefreshScreen(); if (cycle++ >= 3) cycle = 0; totaltextfps++; @@ -2096,7 +2096,7 @@ void VideoBenchmark () { FillMemory(mem+0x2000,0x2000,0x14); else CopyMemory(mem+0x2000,mem+((cycle & 2) ? 0x4000 : 0x6000),0x2000); - VideoRefreshScreen(); + VideoRedrawScreen(); // VideoRefreshScreen(); if (cycle++ >= 3) cycle = 0; totalhiresfps++; @@ -2187,7 +2187,7 @@ void VideoBenchmark () { FillMemory(mem+0x2000,0x2000,0xAA); else CopyMemory(mem+0x2000,mem+((cycle & 2) ? 0x4000 : 0x6000),0x2000); - VideoRefreshScreen(); + VideoRedrawScreen(); // VideoRefreshScreen(); if (cycle++ >= 3) cycle = 0; realisticfps++; @@ -2499,17 +2499,10 @@ void VideoRealizePalette(HDC dc) //=========================================================================== -// Called by DrawFrameWindow() when in fullscreen mode (eg. after WM_PAINT msg) -VideoUpdateFuncPtr_t VideoRedrawScreen (UINT n) -{ - g_VideoForceFullRedraw = n; - return VideoRefreshScreen(); -} - -VideoUpdateFuncPtr_t VideoRedrawScreen () +void VideoRedrawScreen () { g_VideoForceFullRedraw = 1; - return VideoRefreshScreen(); + VideoRefreshScreen( g_uVideoMode ); } //=========================================================================== @@ -2519,12 +2512,14 @@ void _Video_Dirty() } //=========================================================================== -void _Video_SetupBanks( bool bBank2 ) +int _Video_SetupBanks( bool bBank2 ) { g_pHiresBank1 = MemGetAuxPtr (0x2000 << (int)bBank2); g_pHiresBank0 = MemGetMainPtr(0x2000 << (int)bBank2); g_pTextBank1 = MemGetAuxPtr (0x400 << (int)bBank2); g_pTextBank0 = MemGetMainPtr(0x400 << (int)bBank2); + + return bBank2 ? VF_PAGE2 : 0; } //=========================================================================== @@ -2551,12 +2546,15 @@ static void DebugRefresh(char uDebugFlag) } #endif -VideoUpdateFuncPtr_t VideoRefreshScreen () +void VideoRefreshScreen ( int bVideoModeFlags ) { #if defined(_DEBUG) && defined(DEBUG_REFRESH_TIMINGS) DebugRefresh(0); #endif + NTSC_SetVideoMode( bVideoModeFlags ); + g_pNTSC_FuncVideoUpdate( VIDEO_SCANNER_6502_CYCLES ); + // NTSC_BEGIN: wsVideoRefresh() LPBYTE pDstFrameBufferBits = 0; LONG pitch = 0; @@ -2568,189 +2566,16 @@ VideoUpdateFuncPtr_t VideoRefreshScreen () StretchBlt(hFrameDC,0,0,FRAMEBUFFER_W,FRAMEBUFFER_H,g_hDeviceDC,0,0,FRAMEBUFFER_W,FRAMEBUFFER_H,SRCCOPY); GdiFlush(); } - return NULL; + + if (g_VideoForceFullRedraw) + --g_VideoForceFullRedraw; // NTSC_END - - // CHECK EACH CELL FOR CHANGED BYTES. REDRAW PIXELS FOR THE CHANGED BYTES - // IN THE FRAME BUFFER. MARK CELLS IN WHICH REDRAWING HAS TAKEN PLACE AS - // DIRTY. - _Video_Dirty(); - _Video_SetupBanks( SW_PAGE2 != 0 ); - - VideoUpdateFuncPtr_t pfUpdate = SW_TEXT - ? SW_80COL - ? Update80ColCell - : Update40ColCell - : SW_HIRES - ? (SW_DHIRES && SW_80COL) - ? UpdateDHiResCell - : UpdateHiResCell - : (SW_DHIRES && SW_80COL) - ? UpdateDLoResCell - : UpdateLoResCell; - - bool bMixed = (SW_MIXED) ? true : false; - _Video_RedrawScreen( pfUpdate, bMixed ); - - //g_VideoForceFullRedraw = 0; - if (g_VideoForceFullRedraw) --g_VideoForceFullRedraw; - return pfUpdate; } //=========================================================================== -void _Video_RedrawScreen( VideoUpdateFuncPtr_t pfUpdate, bool bMixed ) -{ - LPBYTE pDstFrameBufferBits = 0; - LONG pitch = 0; - HDC hFrameDC = FrameGetVideoDC(&pDstFrameBufferBits,&pitch); - CreateFrameOffsetTable(pDstFrameBufferBits,pitch); // ptr to start of each scanline - - BOOL anydirty = 0; - int y = 0; - int ypixel = 0; - - while (y < 20) { - int offset = ((y & 7) << 7) + ((y >> 3) * 40); - int x = 0; - int xpixel = 0; - while (x < 40) { - anydirty |= celldirty[x][y] = pfUpdate(x,y,xpixel,ypixel,offset+x); - ++x; - xpixel += 14; - } - ++y; - ypixel += 16; - } - - if( bMixed ) { - pfUpdate = SW_80COL - ? Update80ColCell - : Update40ColCell; - } - - while (y < 24) { - int offset = ((y & 7) << 7) + ((y >> 3) * 40); - int x = 0; - int xpixel = 0; - while (x < 40) { - anydirty |= celldirty[x][y] = pfUpdate(x,y,xpixel,ypixel,offset+x); - ++x; - xpixel += 14; - } - ++y; - ypixel += 16; - } - - // Clear this flag after TEXT screen has been updated - g_bTextFlashFlag = false; - -#if 1 - // New simpified code: - // . Oliver Schmidt gets a flickering mouse cursor with this code - if (hFrameDC && anydirty) - { - int nViewportCX, nViewportCY; - GetViewportCXCY(nViewportCX, nViewportCY); - StretchBlt(hFrameDC, 0 ,0, nViewportCX, nViewportCY, g_hDeviceDC, 0, 0, FRAMEBUFFER_W, FRAMEBUFFER_H, SRCCOPY); - GdiFlush(); - } -#else - // Original code: - if (!hFrameDC || !anydirty) - { - FrameReleaseVideoDC(); - SetLastDrawnImage(); - g_VideoForceFullRedraw = 0; - return; - } - - // COPY DIRTY CELLS FROM THE DEVICE DEPENDENT BITMAP ONTO THE SCREEN - // IN LONG HORIZONTAL RECTANGLES - BOOL remainingdirty = 0; - y = 0; - ypixel = 0; - while (y < 24) { - int start = -1; - int startx = 0; - int x = 0; - int xpixel = 0; - while (x < 40) { - if ((x == 39) && celldirty[x][y]) - if (start >= 0) { - xpixel += 14; - celldirty[x][y] = 0; - } - else - remainingdirty = 1; - if ((start >= 0) && !celldirty[x][y]) { - if ((x - startx > 1) || ((x == 39) && (xpixel == FRAMEBUFFER_W))) { - int height = 1; - while ((y+height < 24) - && celldirty[startx][y+height] - && celldirty[x-1][y+height] - && celldirty[(startx+x-1) >> 1][y+height]) - height++; - BitBlt(hFrameDC,start,ypixel,xpixel-start,height << 4, - g_hDeviceDC,start,ypixel,SRCCOPY); - while (height--) { - int loop = startx; - while (loop < x+(xpixel == FRAMEBUFFER_W)) - celldirty[loop++][y+height] = 0; - } - start = -1; - } - else - remainingdirty = 1; - start = -1; - } - else if ((start == -1) && celldirty[x][y] && (x < 39)) { - start = xpixel; - startx = x; - } - x++; - xpixel += 14; - } - y++; - ypixel += 16; - } - - // COPY ANY REMAINING DIRTY CELLS FROM THE DEVICE DEPENDENT BITMAP - // ONTO THE SCREEN IN VERTICAL RECTANGLES - if (remainingdirty) { - int x = 0; - int xpixel = 0; - while (x < 40) { - int start = -1; - int y = 0; - int ypixel = 0; - while (y < 24) { - if ((y == 23) && celldirty[x][y]) { - if (start == -1) - start = ypixel; - ypixel += 16; - celldirty[x][y] = 0; - } - if ((start >= 0) && !celldirty[x][y]) { - BitBlt(hFrameDC,xpixel,start,14,ypixel-start, - g_hDeviceDC,xpixel,start,SRCCOPY); - start = -1; - } - else if ((start == -1) && celldirty[x][y]) - start = ypixel; - y++; - ypixel += 16; - } - x++; - xpixel += 14; - } - } - - GdiFlush(); -#endif - - FrameReleaseVideoDC(); - SetLastDrawnImage(); -} +//void _Video_RedrawScreen( VideoUpdateFuncPtr_t pfUpdate, bool bMixed ) +// FrameReleaseVideoDC(); +// SetLastDrawnImage(); //=========================================================================== void VideoReinitialize () @@ -2820,7 +2645,7 @@ BYTE VideoSetMode (WORD, WORD address, BYTE write, BYTE, ULONG uExecutedCycles) if (!g_bVideoUpdatedThisFrame) { - VideoRefreshScreen(); + VideoRedrawScreen(); // VideoRefreshScreen(); g_bVideoUpdatedThisFrame = true; } } @@ -2870,7 +2695,8 @@ void VideoEndOfVideoFrame(void) if (!g_bFullSpeed || (dwCurrTime-dwLastTime >= 100)) // FullSpeed: update every 100ms { - VideoRefreshScreen(); + // Required or else screen won't update -- Sheldon's NTSC doesn't have VideoEndOfVideoFrame -- simply calls wsVideoRefresh() + VideoRedrawScreen(); // VideoRefreshScreen(); dwLastTime = dwCurrTime; } } diff --git a/source/Video.h b/source/Video.h index 1fb3075e..c5293287 100644 --- a/source/Video.h +++ b/source/Video.h @@ -77,9 +77,8 @@ void VideoDrawLogoBitmap(HDC hDstDC, int xoff, int yoff, int srcw, int srch, void VideoDisplayLogo (); void VideoInitialize (); void VideoRealizePalette (HDC); -VideoUpdateFuncPtr_t VideoRedrawScreen (UINT); -VideoUpdateFuncPtr_t VideoRedrawScreen (); -VideoUpdateFuncPtr_t VideoRefreshScreen (); +void VideoRedrawScreen (); +void VideoRefreshScreen (int bVideoFlags ); void VideoReinitialize (); void VideoResetState (); WORD VideoGetScannerAddress(bool* pbVblBar_OUT, const DWORD uExecutedCycles); @@ -98,8 +97,7 @@ bool VideoGetSWAltCharSet(void); void VideoSetForceFullRedraw(void); void _Video_Dirty(); -void _Video_RedrawScreen( VideoUpdateFuncPtr_t update, bool bMixed = false ); -void _Video_SetupBanks( bool bBank2 ); +int _Video_SetupBanks( bool bBank2 ); bool Update40ColCell (int x, int y, int xpixel, int ypixel, int offset); bool Update80ColCell (int x, int y, int xpixel, int ypixel, int offset); bool UpdateLoResCell (int x, int y, int xpixel, int ypixel, int offset);