mirror of
https://github.com/AppleWin/AppleWin.git
synced 2025-01-01 12:31:59 +00:00
Clean-up to CPU module
. Removed all obsolete DLL code . Simplified CpuCalcCycles() . Split 6502/65C02 emu into 2 funcs . Removed redundant vars: pages, cpuemutype Bug fix #8300 : 80-col text in Silvern Castle got corrupted
This commit is contained in:
parent
9d433c1395
commit
1832b7ccef
@ -46,9 +46,6 @@ bool g_bFullSpeed = false;
|
|||||||
// Win32
|
// Win32
|
||||||
HINSTANCE g_hInstance = (HINSTANCE)0;
|
HINSTANCE g_hInstance = (HINSTANCE)0;
|
||||||
|
|
||||||
static DWORD lastfastpaging = 0;
|
|
||||||
static DWORD lasttrimimages = 0;
|
|
||||||
|
|
||||||
AppMode_e g_nAppMode = MODE_LOGO;
|
AppMode_e g_nAppMode = MODE_LOGO;
|
||||||
|
|
||||||
static int lastmode = MODE_LOGO;
|
static int lastmode = MODE_LOGO;
|
||||||
@ -70,21 +67,6 @@ bool g_bDisableDirectSound = false;
|
|||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
void CheckFastPaging ()
|
|
||||||
{
|
|
||||||
if ((pages >= 10) && CpuSupportsFastPaging())
|
|
||||||
{
|
|
||||||
lastfastpaging = cumulativecycles;
|
|
||||||
if (cpuemtype == CPU_COMPILING)
|
|
||||||
{
|
|
||||||
lasttrimimages = cumulativecycles;
|
|
||||||
MemSetFastPaging(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
#define DBG_CALC_FREQ 0
|
#define DBG_CALC_FREQ 0
|
||||||
#if DBG_CALC_FREQ
|
#if DBG_CALC_FREQ
|
||||||
const UINT MAX_CNT = 256;
|
const UINT MAX_CNT = 256;
|
||||||
@ -145,7 +127,6 @@ void ContinueExecution()
|
|||||||
|
|
||||||
cyclenum = dwExecutedCycles;
|
cyclenum = dwExecutedCycles;
|
||||||
|
|
||||||
CheckFastPaging();
|
|
||||||
DiskUpdatePosition(dwExecutedCycles);
|
DiskUpdatePosition(dwExecutedCycles);
|
||||||
JoyUpdatePosition();
|
JoyUpdatePosition();
|
||||||
VideoUpdateVbl(g_dwCyclesThisFrame);
|
VideoUpdateVbl(g_dwCyclesThisFrame);
|
||||||
@ -155,21 +136,6 @@ void ContinueExecution()
|
|||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
if (cpuemtype == CPU_FASTPAGING) //?
|
|
||||||
{
|
|
||||||
if ((!pages) && (cumulativecycles-lastfastpaging > 500000))
|
|
||||||
{
|
|
||||||
MemSetFastPaging(0);
|
|
||||||
}
|
|
||||||
else if (cumulativecycles-lasttrimimages > 500000)
|
|
||||||
{
|
|
||||||
MemTrimImages();
|
|
||||||
lasttrimimages = cumulativecycles;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
const DWORD CLKS_PER_MS = (DWORD)g_fCurrentCLK6502 / 1000;
|
const DWORD CLKS_PER_MS = (DWORD)g_fCurrentCLK6502 / 1000;
|
||||||
|
|
||||||
emulmsec_frac += dwExecutedCycles;
|
emulmsec_frac += dwExecutedCycles;
|
||||||
@ -179,8 +145,6 @@ void ContinueExecution()
|
|||||||
emulmsec_frac %= CLKS_PER_MS;
|
emulmsec_frac %= CLKS_PER_MS;
|
||||||
}
|
}
|
||||||
|
|
||||||
pages = 0; //?
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// DETERMINE WHETHER THE SCREEN WAS UPDATED, THE DISK WAS SPINNING,
|
// DETERMINE WHETHER THE SCREEN WAS UPDATED, THE DISK WAS SPINNING,
|
||||||
// OR THE KEYBOARD I/O PORTS WERE BEING EXCESSIVELY QUERIED THIS CLOCKTICK
|
// OR THE KEYBOARD I/O PORTS WERE BEING EXCESSIVELY QUERIED THIS CLOCKTICK
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define CPU_COMPILING 0
|
|
||||||
#define CPU_INTERPRETIVE 1
|
|
||||||
#define CPU_FASTPAGING 2
|
|
||||||
|
|
||||||
typedef struct _regsrec {
|
typedef struct _regsrec {
|
||||||
BYTE a; // accumulator
|
BYTE a; // accumulator
|
||||||
BYTE x; // index X
|
BYTE x; // index X
|
||||||
@ -14,20 +10,15 @@ typedef struct _regsrec {
|
|||||||
BYTE bJammed; // CPU has crashed (NMOS 6502 only)
|
BYTE bJammed; // CPU has crashed (NMOS 6502 only)
|
||||||
} regsrec, *regsptr;
|
} regsrec, *regsptr;
|
||||||
|
|
||||||
extern DWORD cpuemtype;
|
|
||||||
extern regsrec regs;
|
extern regsrec regs;
|
||||||
extern unsigned __int64 g_nCumulativeCycles;
|
extern unsigned __int64 g_nCumulativeCycles;
|
||||||
|
|
||||||
void CpuDestroy ();
|
void CpuDestroy ();
|
||||||
void CpuCalcCycles(ULONG nCyclesLeft);
|
void CpuCalcCycles(ULONG nCyclesLeft);
|
||||||
DWORD CpuExecute (DWORD);
|
DWORD CpuExecute (DWORD);
|
||||||
void CpuGetCode (WORD,LPBYTE *,DWORD *);
|
|
||||||
ULONG CpuGetCyclesThisFrame();
|
ULONG CpuGetCyclesThisFrame();
|
||||||
void CpuInitialize ();
|
void CpuInitialize ();
|
||||||
void CpuReinitialize ();
|
|
||||||
void CpuResetCompilerData ();
|
|
||||||
void CpuSetupBenchmark ();
|
void CpuSetupBenchmark ();
|
||||||
BOOL CpuSupportsFastPaging ();
|
|
||||||
void CpuIrqReset();
|
void CpuIrqReset();
|
||||||
void CpuIrqAssert(eIRQSRC Device);
|
void CpuIrqAssert(eIRQSRC Device);
|
||||||
void CpuIrqDeassert(eIRQSRC Device);
|
void CpuIrqDeassert(eIRQSRC Device);
|
||||||
|
@ -8147,11 +8147,6 @@ void DebugBegin ()
|
|||||||
// This is called every time the emulator is reset.
|
// This is called every time the emulator is reset.
|
||||||
// And everytime the debugger is entered.
|
// And everytime the debugger is entered.
|
||||||
|
|
||||||
if (cpuemtype == CPU_FASTPAGING)
|
|
||||||
{
|
|
||||||
MemSetFastPaging(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_nAppMode = MODE_DEBUG;
|
g_nAppMode = MODE_DEBUG;
|
||||||
FrameRefreshStatus(DRAW_TITLE);
|
FrameRefreshStatus(DRAW_TITLE);
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ static DWORD imagemode[MAXIMAGES];
|
|||||||
LPBYTE memshadow[MAXIMAGES][0x100];
|
LPBYTE memshadow[MAXIMAGES][0x100];
|
||||||
LPBYTE memwrite[MAXIMAGES][0x100];
|
LPBYTE memwrite[MAXIMAGES][0x100];
|
||||||
|
|
||||||
static BOOL fastpaging = 0;
|
static BOOL fastpaging = 0; // Redundant: only ever set to 0, by MemSetFastPaging(0)
|
||||||
DWORD image = 0;
|
DWORD image = 0;
|
||||||
DWORD lastimage = 0;
|
DWORD lastimage = 0;
|
||||||
static BOOL lastwriteram = 0;
|
static BOOL lastwriteram = 0;
|
||||||
@ -593,7 +593,6 @@ static LPBYTE memmain = NULL;
|
|||||||
static DWORD memmode = MF_BANK2 | MF_SLOTCXROM | MF_WRITERAM;
|
static DWORD memmode = MF_BANK2 | MF_SLOTCXROM | MF_WRITERAM;
|
||||||
static LPBYTE memrom = NULL;
|
static LPBYTE memrom = NULL;
|
||||||
static BOOL modechanging = 0;
|
static BOOL modechanging = 0;
|
||||||
DWORD pages = 0;
|
|
||||||
|
|
||||||
MemoryInitPattern_e g_eMemoryInitPattern = MIP_FF_FF_00_00;
|
MemoryInitPattern_e g_eMemoryInitPattern = MIP_FF_FF_00_00;
|
||||||
|
|
||||||
@ -672,7 +671,6 @@ void UpdateFastPaging () {
|
|||||||
mem = memimage+(image << 16);
|
mem = memimage+(image << 16);
|
||||||
UpdatePaging(1,0);
|
UpdatePaging(1,0);
|
||||||
}
|
}
|
||||||
CpuReinitialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
@ -1049,10 +1047,6 @@ void MemSetFastPaging (BOOL on) {
|
|||||||
imagemode[0] = memmode;
|
imagemode[0] = memmode;
|
||||||
if (!fastpaging)
|
if (!fastpaging)
|
||||||
UpdatePaging(1,0);
|
UpdatePaging(1,0);
|
||||||
cpuemtype = fastpaging ? CPU_FASTPAGING : CPU_COMPILING;
|
|
||||||
CpuReinitialize();
|
|
||||||
if (cpuemtype == CPU_COMPILING)
|
|
||||||
CpuResetCompilerData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
@ -1108,8 +1102,6 @@ BYTE __stdcall MemSetPaging (WORD programcounter, BYTE address, BYTE write, BYTE
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
UpdatePaging(0,0);
|
UpdatePaging(0,0);
|
||||||
if (cpuemtype == CPU_COMPILING)
|
|
||||||
CpuResetCompilerData();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1136,7 +1128,6 @@ BYTE __stdcall MemSetPaging (WORD programcounter, BYTE address, BYTE write, BYTE
|
|||||||
// WRITE TABLES.
|
// WRITE TABLES.
|
||||||
if ((lastmemmode != memmode) || modechanging) {
|
if ((lastmemmode != memmode) || modechanging) {
|
||||||
modechanging = 0;
|
modechanging = 0;
|
||||||
++pages;
|
|
||||||
|
|
||||||
// IF FAST PAGING IS ACTIVE, WE KEEP MULTIPLE COMPLETE MEMORY IMAGES
|
// IF FAST PAGING IS ACTIVE, WE KEEP MULTIPLE COMPLETE MEMORY IMAGES
|
||||||
// AND WRITE TABLES, AND SWITCH BETWEEN THEM. THE FAST PAGING VERSION
|
// AND WRITE TABLES, AND SWITCH BETWEEN THEM. THE FAST PAGING VERSION
|
||||||
@ -1148,8 +1139,6 @@ BYTE __stdcall MemSetPaging (WORD programcounter, BYTE address, BYTE write, BYTE
|
|||||||
// WRITE TABLE, AND UPDATE THEM EVERY TIME PAGING IS CHANGED.
|
// WRITE TABLE, AND UPDATE THEM EVERY TIME PAGING IS CHANGED.
|
||||||
else {
|
else {
|
||||||
UpdatePaging(0,0);
|
UpdatePaging(0,0);
|
||||||
if (cpuemtype == CPU_COMPILING)
|
|
||||||
CpuResetCompilerData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1181,7 +1170,6 @@ void MemTrimImages () {
|
|||||||
image = realimage;
|
image = realimage;
|
||||||
mem = memimage+(image << 16);
|
mem = memimage+(image << 16);
|
||||||
memmode = imagemode[image];
|
memmode = imagemode[image];
|
||||||
CpuReinitialize();
|
|
||||||
}
|
}
|
||||||
if (++trimnumber >= lastimage)
|
if (++trimnumber >= lastimage)
|
||||||
trimnumber = 0;
|
trimnumber = 0;
|
||||||
@ -1270,7 +1258,6 @@ DWORD MemSetSnapshot(SS_BaseMemory* pSS)
|
|||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
pages = 0;
|
|
||||||
modechanging = 0;
|
modechanging = 0;
|
||||||
|
|
||||||
UpdatePaging(1,0); // Initialize=1, UpdateWriteOnly=0
|
UpdatePaging(1,0); // Initialize=1, UpdateWriteOnly=0
|
||||||
|
@ -17,7 +17,6 @@ extern DWORD image;
|
|||||||
extern DWORD lastimage;
|
extern DWORD lastimage;
|
||||||
extern LPBYTE mem;
|
extern LPBYTE mem;
|
||||||
extern LPBYTE memdirty;
|
extern LPBYTE memdirty;
|
||||||
extern DWORD pages;
|
|
||||||
|
|
||||||
#ifdef RAMWORKS
|
#ifdef RAMWORKS
|
||||||
extern UINT g_uMaxExPages; // user requested ram pages (from cmd line)
|
extern UINT g_uMaxExPages; // user requested ram pages (from cmd line)
|
||||||
|
@ -986,7 +986,7 @@ void SetLastDrawnImage () {
|
|||||||
memcpy(vidlastmem+0x2000,g_pHiresBank0,0x2000);
|
memcpy(vidlastmem+0x2000,g_pHiresBank0,0x2000);
|
||||||
if (SW_DHIRES && SW_HIRES)
|
if (SW_DHIRES && SW_HIRES)
|
||||||
memcpy(vidlastmem,g_pHiresBank1,0x2000);
|
memcpy(vidlastmem,g_pHiresBank1,0x2000);
|
||||||
if (SW_80COL && !SW_HIRES)
|
else if (SW_80COL) // Don't test for !SW_HIRES, as some 80-col text routines have SW_HIRES set (Bug #8300)
|
||||||
memcpy(vidlastmem,g_pTextBank1,0x400);
|
memcpy(vidlastmem,g_pTextBank1,0x400);
|
||||||
int loop;
|
int loop;
|
||||||
for (loop = 0; loop < 256; loop++)
|
for (loop = 0; loop < 256; loop++)
|
||||||
@ -2079,10 +2079,7 @@ BYTE __stdcall VideoSetMode (WORD, BYTE address, BYTE write, BYTE, ULONG) {
|
|||||||
}
|
}
|
||||||
if (oldpage2 != SW_PAGE2) {
|
if (oldpage2 != SW_PAGE2) {
|
||||||
static DWORD lastrefresh = 0;
|
static DWORD lastrefresh = 0;
|
||||||
BOOL fastvideoslowcpu = 0;
|
if ((displaypage2 && !SW_PAGE2) || (!behind)) {
|
||||||
if ((cpuemtype == CPU_FASTPAGING) && (emulmsec-lastrefresh >= 20))
|
|
||||||
fastvideoslowcpu = 1;
|
|
||||||
if ((displaypage2 && !SW_PAGE2) || (!behind) || fastvideoslowcpu) {
|
|
||||||
displaypage2 = (SW_PAGE2 != 0);
|
displaypage2 = (SW_PAGE2 != 0);
|
||||||
if (!redrawfull) {
|
if (!redrawfull) {
|
||||||
VideoRefreshScreen();
|
VideoRefreshScreen();
|
||||||
|
Loading…
Reference in New Issue
Block a user