mirror of
https://github.com/AppleWin/AppleWin.git
synced 2025-01-22 01:31:25 +00:00
Optimize rendering so it doesn't hog the CPU
This commit is contained in:
parent
c3470c6e6f
commit
e98a0f5f7e
@ -322,10 +322,7 @@ static DWORD Cpu6502 (DWORD uTotalCycles)
|
||||
|
||||
// NTSC_BEGIN
|
||||
uElapsedCycles = uExecutedCycles - uPreviousCycles;
|
||||
if( g_bFullSpeed )
|
||||
NTSC_VideoUpdateCycles( uElapsedCycles );
|
||||
else
|
||||
g_pFunc_NTSCVideoUpdateGraphics( uElapsedCycles );
|
||||
NTSC_VideoUpdateCycles( uElapsedCycles );
|
||||
// NTSC_END
|
||||
|
||||
CheckInterruptSources(uExecutedCycles);
|
||||
|
@ -326,10 +326,7 @@ static DWORD Cpu65C02 (DWORD uTotalCycles)
|
||||
|
||||
// NTSC_BEGIN
|
||||
uElapsedCycles = uExecutedCycles - uPreviousCycles;
|
||||
if( g_bFullSpeed )
|
||||
NTSC_VideoUpdateCycles( uElapsedCycles );
|
||||
else
|
||||
g_pFunc_NTSCVideoUpdateGraphics( uElapsedCycles );
|
||||
NTSC_VideoUpdateCycles( uElapsedCycles );
|
||||
// NTSC_END
|
||||
|
||||
CheckInterruptSources(uExecutedCycles);
|
||||
|
@ -655,10 +655,7 @@ static DWORD Cpu65D02 (DWORD uTotalCycles)
|
||||
|
||||
// NTSC_BEGIN
|
||||
uElapsedCycles = uExecutedCycles - uPreviousCycles;
|
||||
if( g_bFullSpeed )
|
||||
NTSC_VideoUpdateCycles( uElapsedCycles );
|
||||
else
|
||||
g_pFunc_NTSCVideoUpdateGraphics( uElapsedCycles );
|
||||
NTSC_VideoUpdateCycles( uElapsedCycles );
|
||||
// NTSC_END
|
||||
|
||||
CheckInterruptSources(uExecutedCycles);
|
||||
|
@ -132,6 +132,17 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
bgra_t *g_pVideoAddress;
|
||||
bgra_t *g_aNTSC_Lines[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;
|
||||
|
||||
typedef void (*Func_t)(long);
|
||||
static Func_t g_apFuncVideoUpdateScanline[VIDEO_SCANNER_Y_DISPLAY];
|
||||
|
||||
static void (* g_pFunc_NTSCVideoUpdateText )(long) = 0; // NTSC_UpdateVideoText40;
|
||||
void (* g_pFunc_NTSCVideoUpdateGraphics)(long) = 0; // NTSC_UpdateVideoText40;
|
||||
|
||||
static void (*g_pFunc_ntscMonoPixel )(int) = 0; //ntscMonoSinglePixel ;
|
||||
static void (*g_pFunc_ntscColorPixel)(int) = 0; //ntscColorSinglePixel;
|
||||
|
||||
|
||||
static unsigned g_nTextFlashCounter = 0;
|
||||
static uint16_t g_nTextFlashMask = 0;
|
||||
@ -368,17 +379,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
};
|
||||
|
||||
|
||||
static unsigned (*g_pHorzClockOffset)[VIDEO_SCANNER_MAX_HORZ] = 0;
|
||||
|
||||
static void (* g_pFunc_NTSCVideoUpdateText )(long) = 0; // NTSC_UpdateVideoText40;
|
||||
void (* g_pFunc_NTSCVideoUpdateGraphics)(long) = 0; // NTSC_UpdateVideoText40;
|
||||
|
||||
static void (*g_pFunc_ntscMonoPixel )(int) = 0; //ntscMonoSinglePixel ;
|
||||
static void (*g_pFunc_ntscColorPixel)(int) = 0; //ntscColorSinglePixel;
|
||||
|
||||
typedef void (*Func_t)(long);
|
||||
static Func_t g_apFuncVideoUpdateScanline[VIDEO_SCANNER_Y_DISPLAY];
|
||||
|
||||
// Prototypes
|
||||
// prototype from CPU.h
|
||||
//unsigned char CpuRead(unsigned short addr, unsigned long uExecutedCycles);
|
||||
@ -1479,11 +1479,15 @@ int NTSC_VideoIsVbl ()
|
||||
//===========================================================================
|
||||
void NTSC_VideoUpdateCycles( long cycles6502 )
|
||||
{
|
||||
bool bRedraw = false;
|
||||
bool bRedraw = cycles6502 >= VIDEO_SCANNER_6502_CYCLES;
|
||||
|
||||
// if( !g_bFullSpeed )
|
||||
// if( g_bFullSpeed )
|
||||
// g_pFunc_NTSCVideoUpdateGraphics( cycles6502 );
|
||||
// else
|
||||
|
||||
while( cycles6502 > VIDEO_SCANNER_6502_CYCLES )
|
||||
/* */ cycles6502 -= VIDEO_SCANNER_6502_CYCLES ;
|
||||
|
||||
for( ; cycles6502 > 0; cycles6502-- )
|
||||
{
|
||||
if (VIDEO_SCANNER_MAX_HORZ == ++g_nVideoClockHorz)
|
||||
@ -1515,9 +1519,7 @@ void NTSC_VideoUpdateCycles( long cycles6502 )
|
||||
if( bRedraw ) // Force full refresh
|
||||
{
|
||||
for( int y = 0; y < VIDEO_SCANNER_Y_DISPLAY; y++ )
|
||||
{
|
||||
g_apFuncVideoUpdateScanline[ y ]( VIDEO_SCANNER_MAX_HORZ );
|
||||
}
|
||||
|
||||
int nCyclesVBlank = (VIDEO_SCANNER_MAX_VERT - VIDEO_SCANNER_Y_DISPLAY) * VIDEO_SCANNER_MAX_HORZ;
|
||||
g_pFunc_NTSCVideoUpdateGraphics( nCyclesVBlank );
|
||||
|
@ -1,9 +1,9 @@
|
||||
#define VIDEO_SCANNER_6502_CYCLES 17030
|
||||
// Constants
|
||||
const int VIDEO_SCANNER_6502_CYCLES = 17030;
|
||||
|
||||
// Globals (Public)
|
||||
extern uint16_t g_nVideoClockVert;
|
||||
extern uint16_t g_nVideoClockHorz;
|
||||
extern void (* g_pFunc_NTSCVideoUpdateGraphics)(long);
|
||||
|
||||
// Prototypes (Public) ________________________________________________
|
||||
extern void NTSC_SetVideoTextMode( int cols );
|
||||
|
@ -1266,7 +1266,7 @@ void VideoRefreshScreen ( int bVideoModeFlags )
|
||||
if( bVideoModeFlags )
|
||||
{
|
||||
NTSC_SetVideoMode( bVideoModeFlags );
|
||||
g_pFunc_NTSCVideoUpdateGraphics( VIDEO_SCANNER_6502_CYCLES );
|
||||
NTSC_VideoUpdateCycles( VIDEO_SCANNER_6502_CYCLES );
|
||||
}
|
||||
|
||||
// NTSC_BEGIN: wsVideoRefresh()
|
||||
@ -1341,7 +1341,7 @@ BYTE VideoSetMode (WORD, WORD address, BYTE write, BYTE, ULONG uExecutedCycles)
|
||||
// NTSC_BEGIN
|
||||
NTSC_SetVideoMode( g_uVideoMode );
|
||||
// NTSC_END
|
||||
|
||||
#if 0 // NTSC_CLEANUP: Is this still needed??
|
||||
if (SW_80STORE)
|
||||
g_uVideoMode &= ~VF_PAGE2;
|
||||
|
||||
@ -1364,7 +1364,7 @@ BYTE VideoSetMode (WORD, WORD address, BYTE write, BYTE, ULONG uExecutedCycles)
|
||||
g_bVideoUpdatedThisFrame = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NTSC_CLEANUP
|
||||
return MemReadFloatingBus(uExecutedCycles);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user