This commit is contained in:
dinkc64 2019-05-10 20:16:55 -04:00
parent ddd14379a7
commit fef32c8395
8 changed files with 64 additions and 38 deletions

View File

@ -329,6 +329,8 @@ void ArmReset(void)
R15 = eARM_MODE_SVC|I_MASK|F_MASK;
}
static int end_run = 0;
int ArmRun( int cycles )
{
UINT32 pc;
@ -336,6 +338,7 @@ int ArmRun( int cycles )
arm_icount = cycles;
arm.ArmLeftCycles = cycles;
end_run = 0;
do
{
@ -436,11 +439,16 @@ int ArmRun( int cycles )
arm_check_irq_state();
} while( arm_icount > 0 );
} while( arm_icount > 0 && !end_run );
arm.ArmTotalCycles += (cycles - arm_icount);
cycles = cycles - arm_icount;
return cycles - arm_icount;
arm.ArmTotalCycles += cycles;
arm_icount = 0;
arm.ArmLeftCycles = 0;
return cycles;
} /* arm_execute */
static void arm_check_irq_state(void)
@ -1404,7 +1412,7 @@ void ArmRunEnd()
if (!DebugCPU_ARMInitted) bprintf(PRINT_ERROR, _T("ArmRunEnd called without init\n"));
#endif
arm_icount = 0;
end_run = 1;
}
INT32 ArmIdle(INT32 cycles)
@ -1422,8 +1430,6 @@ void ArmNewFrame()
#endif
arm.ArmTotalCycles = 0;
arm_icount = 0;
arm.ArmLeftCycles = 0;
}
int ArmScan(int nAction)

View File

@ -90,6 +90,7 @@ static ARM7_REGS arm7;
static int ARM7_ICOUNT;
static int total_cycles = 0;
static int curr_cycles = 0;
static int end_run = 0;
void Arm7Open(int )
{
@ -107,7 +108,7 @@ int Arm7TotalCycles()
if (!DebugCPU_ARM7Initted) bprintf(PRINT_ERROR, _T("Arm7TotalCycles called without init\n"));
#endif
return total_cycles;
return total_cycles + (curr_cycles - ARM7_ICOUNT);
}
void Arm7RunEnd()
@ -116,7 +117,7 @@ void Arm7RunEnd()
if (!DebugCPU_ARM7Initted) bprintf(PRINT_ERROR, _T("Arm7RunEnd called without init\n"));
#endif
arm7_icount = 0;
end_run = 1;
}
void Arm7BurnCycles(int cycles)
@ -125,7 +126,7 @@ void Arm7BurnCycles(int cycles)
if (!DebugCPU_ARM7Initted) bprintf(PRINT_ERROR, _T("Arm7BurnCycles called without init\n"));
#endif
arm7_icount -= cycles;
ARM7_ICOUNT -= cycles;
}
INT32 Arm7Idle(int cycles)

View File

@ -45,7 +45,8 @@
UINT32 insn;
ARM7_ICOUNT = cycles;
curr_cycles = total_cycles;
curr_cycles = cycles;
end_run = 0;
do
{
@ -1359,8 +1360,11 @@
/* All instructions remove 3 cycles.. Others taking less / more will have adjusted this # prior to here */
ARM7_ICOUNT -= 3;
total_cycles = curr_cycles + cycles - ARM7_ICOUNT;
} while (ARM7_ICOUNT > 0);
} while (ARM7_ICOUNT > 0 && !end_run);
return cycles - ARM7_ICOUNT;
cycles = curr_cycles - ARM7_ICOUNT;
total_cycles += cycles;
curr_cycles = ARM7_ICOUNT = 0;
return cycles;
}

View File

@ -226,6 +226,8 @@ static void h6280_exit(void)
}
#endif
static int end_run = 0;
int h6280Run(int cycles)
{
#if defined FBA_DEBUG
@ -237,6 +239,8 @@ int h6280Run(int cycles)
h6280_ICount = cycles;
h6280.h6280_iCycles = cycles;
end_run = 0;
if ( h6280.irq_pending == 2 ) {
h6280.irq_pending--;
}
@ -278,13 +282,15 @@ int h6280Run(int cycles)
set_irq_line(2,ASSERT_LINE);
}
}
} while (h6280_ICount > 0);
} while (h6280_ICount > 0 && !end_run);
h6280.h6280_totalcycles += cycles - h6280_ICount;
cycles = cycles - h6280_ICount;
h6280.h6280_totalcycles += cycles;
h6280_ICount = 0;
h6280.h6280_iCycles = 0;
return cycles - h6280_ICount;
return cycles;
}
void h6280_get_context(void *dst)
@ -307,7 +313,7 @@ int h6280TotalCycles()
if (nh6280CpuActive == -1) bprintf(PRINT_ERROR, _T("h6280TotalCycles called with no CPU open\n"));
#endif
return h6280.h6280_totalcycles + (h6280.h6280_iCycles - h6280_ICount);;
return h6280.h6280_totalcycles + (h6280.h6280_iCycles - h6280_ICount);
}
void h6280RunEnd()
@ -317,7 +323,7 @@ void h6280RunEnd()
if (nh6280CpuActive == -1) bprintf(PRINT_ERROR, _T("h6280RunEnd called with no CPU open\n"));
#endif
h6280_ICount = 0;
end_run = 1;
}
INT32 h6280Idle(INT32 cycles)

View File

@ -208,7 +208,8 @@ static PAIR ea; /* effective address */
#define HD6309_LDS 32 /* set when LDS occured at least once */
/* public globals */
static int hd6309_ICount;
static int hd6309_ICount = 0;
static int hd6309_startcycles = 0;
/* these are re-defined in hd6309.h TO RAM, ROM or functions in cpuintrf.c */
#define RM(mAddr) HD6309_RDMEM(mAddr)
@ -622,12 +623,22 @@ void hd6309_set_irq_line(int irqline, int state)
/* includes the actual opcode implementations */
#include "6309ops.c"
static int end_run = 0;
int hd6309_segmentcycles()
{
return hd6309_startcycles - hd6309_ICount;
}
/* execute instructions on this CPU until icount expires */
int hd6309_execute(int cycles) /* NS 970908 */
{
hd6309_startcycles = cycles;
hd6309_ICount = cycles - hd6309.extra_cycles;
hd6309.extra_cycles = 0;
end_run = 0;
if (hd6309.int_state & (HD6309_CWAI | HD6309_SYNC))
{
// debugger_instruction_hook(Machine, PCD);
@ -910,13 +921,16 @@ int hd6309_execute(int cycles) /* NS 970908 */
hd6309_ICount -= cycle_counts_page0[hd6309.ireg];
} while( hd6309_ICount > 0 );
} while( hd6309_ICount > 0 && !end_run );
hd6309_ICount -= hd6309.extra_cycles;
hd6309.extra_cycles = 0;
}
return cycles - hd6309_ICount; /* NS 970908 */
cycles = hd6309_startcycles - hd6309_ICount;
hd6309_ICount = hd6309_startcycles = 0;
return cycles;
}
void HD6309RunEnd()
@ -926,7 +940,7 @@ void HD6309RunEnd()
// if (nActiveCPU == -1) bprintf(PRINT_ERROR, _T("HD6309RunEnd called when no CPU open\n"));
#endif
hd6309_ICount = 0;
end_run = 1;
}
HD6309_INLINE void fetch_effective_address( void )

View File

@ -46,6 +46,7 @@ void hd6309_init();
void hd6309_reset(void);
int hd6309_get_pc();
int hd6309_execute(int cycles);
int hd6309_segmentcycles();
void hd6309_set_irq_line(int irqline, int state);
void hd6309_get_context(void *dst);
void hd6309_set_context(void *src);

View File

@ -76,6 +76,15 @@ void HD6309Reset()
hd6309_reset();
}
INT32 HD6309TotalCycles()
{
#if defined FBA_DEBUG
if (!DebugCPU_HD6309Initted) bprintf(PRINT_ERROR, _T("HD6309TotalCycles called without init\n"));
#endif
return nHD6309CyclesTotal + hd6309_segmentcycles();
}
void HD6309NewFrame()
{
#if defined FBA_DEBUG
@ -462,9 +471,6 @@ INT32 HD6309Scan(INT32 nAction)
ba.szName = szName;
BurnAcb(&ba);
SCAN_VAR(HD6309CPUContext[i].nCyclesTotal);
SCAN_VAR(HD6309CPUContext[i].nCyclesSegment);
SCAN_VAR(HD6309CPUContext[i].nCyclesLeft);
SCAN_VAR(nHD6309CyclesDone[i]);
}

View File

@ -15,10 +15,6 @@ struct HD6309Ext {
pWriteByteHandler WriteByte;
pReadOpHandler ReadOp;
pReadOpArgHandler ReadOpArg;
INT32 nCyclesTotal;
INT32 nCyclesSegment;
INT32 nCyclesLeft;
};
extern INT32 nHD6309Count;
@ -26,6 +22,7 @@ extern INT32 nHD6309Count;
extern INT32 nHD6309CyclesTotal;
void HD6309Reset();
INT32 HD6309TotalCycles();
void HD6309NewFrame();
INT32 HD6309Init(INT32 nCPU);
void HD6309Exit();
@ -47,15 +44,6 @@ INT32 HD6309Scan(INT32 nAction);
void HD6309WriteRom(UINT16 Address, UINT8 Data);
inline static INT32 HD6309TotalCycles()
{
#if defined FBA_DEBUG
if (!DebugCPU_HD6309Initted) bprintf(PRINT_ERROR, _T("HD6309TotalCycles called without init\n"));
#endif
return nHD6309CyclesTotal;
}
void HD6309CheatWriteRom(UINT32 a, UINT8 d); // cheat core
UINT8 HD6309CheatRead(UINT32 a); // cheat core