huge changes to cpus and stuff(over the next few days), update at your own risk

This commit is contained in:
dinkc64 2019-05-10 09:14:15 -04:00
parent 1bfa876c36
commit c533c1162e
12 changed files with 101 additions and 57 deletions

View File

@ -505,6 +505,8 @@ void konami_set_irq_line(int irqline, int state)
/* includes the actual opcode implementations */
#include "konamops.c"
static int end_run = 0;
/* execute instructions on this CPU until icount expires */
int konamiRun(int cycles)
{
@ -513,9 +515,11 @@ int konamiRun(int cycles)
#endif
konami_ICount = cycles - konami.extra_cycles;
nCyclesToDo = konami_ICount;
nCyclesToDo = cycles;
konami.extra_cycles = 0;
end_run = 0;
if( konami.int_state & (KONAMI_CWAI | KONAMI_SYNC) )
{
konami_ICount = 0;
@ -533,14 +537,17 @@ int konamiRun(int cycles)
konami_ICount -= cycles1[konami.ireg];
} while( konami_ICount > 0 );
} while( konami_ICount > 0 && !end_run );
konami_ICount -= konami.extra_cycles;
konami.extra_cycles = 0;
}
konami.nTotalCycles += cycles - konami_ICount;
return cycles - konami_ICount;
cycles = cycles - konami_ICount;
konami.nTotalCycles += cycles;
nCyclesToDo = konami_ICount = 0;
return cycles;
}
int konamiCpuScan(int nAction)
@ -570,7 +577,7 @@ void konamiRunEnd()
if (!DebugCPU_KonamiInitted) bprintf(PRINT_ERROR, _T("konamiRunEnd called without init\n"));
#endif
konami_ICount = 0;
end_run = 1;
}
INT32 konamiIdle(INT32 cycles)
@ -598,7 +605,7 @@ int konamiTotalCycles()
if (!DebugCPU_KonamiInitted) bprintf(PRINT_ERROR, _T("konamiTotalCycles called without init\n"));
#endif
return konami.nTotalCycles;
return konami.nTotalCycles + (nCyclesToDo - konami_ICount);
}
void konamiNewFrame()

View File

@ -243,6 +243,7 @@ int m6502_releaseslice()
}
static int segmentcycles = 0;
static int end_run = 0;
int m6502_get_segmentcycles()
{
@ -254,6 +255,8 @@ int m6502_execute(int cycles)
segmentcycles = cycles;
m6502_ICount = cycles;
end_run = 0;
change_pc(PCD);
do
@ -300,7 +303,7 @@ int m6502_execute(int cycles)
}
}
} while (m6502_ICount > 0);
} while (m6502_ICount > 0 && !end_run);
cycles = cycles - m6502_ICount;
@ -314,6 +317,8 @@ int decocpu7_execute(int cycles)
segmentcycles = cycles;
m6502_ICount = cycles;
end_run = 0;
change_pc(PCD);
do
@ -367,7 +372,7 @@ int decocpu7_execute(int cycles)
}
}
} while (m6502_ICount > 0);
} while (m6502_ICount > 0 && !end_run);
cycles = cycles - m6502_ICount;
@ -560,6 +565,8 @@ int m65c02_execute(int cycles)
segmentcycles = cycles;
m6502_ICount = cycles;
end_run = 0;
change_pc(PCD);
do
@ -598,7 +605,7 @@ int m65c02_execute(int cycles)
if( m6502.pending_irq )
m65c02_take_irq();
} while (m6502_ICount > 0);
} while (m6502_ICount > 0 && !end_run);
cycles = cycles - m6502_ICount;
@ -744,6 +751,8 @@ int deco16_execute(int cycles)
segmentcycles = cycles;
m6502_ICount = cycles;
end_run = 0;
change_pc(PCD);
do
@ -781,7 +790,7 @@ int deco16_execute(int cycles)
if( m6502.pending_irq )
deco16_take_irq();
} while (m6502_ICount > 0);
} while (m6502_ICount > 0 && !end_run);
cycles = cycles - m6502_ICount;
@ -798,7 +807,7 @@ void M6502RunEnd()
if (!DebugCPU_M6502Initted) bprintf(PRINT_ERROR, _T("M6502RunEnd called without init\n"));
#endif
m6502_ICount = 0;
end_run = 1;
}
#if 0

View File

@ -658,6 +658,8 @@ int m6800_get_segmentcycles()
return m6800.segmentcycles - m6800_ICount;
}
static INT32 end_run;
/****************************************************************************
* Execute cycles CPU cycles. Return number of cycles really executed
****************************************************************************/
@ -673,6 +675,8 @@ int m6800_execute(int cycles)
INCREMENT_COUNTER(m6800.extra_cycles);
m6800.extra_cycles = 0;
end_run = 0;
do
{
if( m6800.wai_state & (M6800_WAI|M6800_SLP) )
@ -689,7 +693,7 @@ int m6800_execute(int cycles)
INCREMENT_COUNTER(cycles_6800[ireg]);
}
} while( m6800_ICount>0 );
} while( m6800_ICount>0 && !end_run );
INCREMENT_COUNTER(m6800.extra_cycles);
m6800.extra_cycles = 0;
@ -758,6 +762,8 @@ int m6803_execute(int cycles)
INCREMENT_COUNTER(m6803.extra_cycles);
m6803.extra_cycles = 0;
end_run = 0;
do
{
if( m6803.wai_state & M6800_WAI )
@ -774,7 +780,7 @@ int m6803_execute(int cycles)
INCREMENT_COUNTER(cycles_6803[ireg]);
}
} while( m6800_ICount>0 );
} while( m6800_ICount>0 && !end_run );
INCREMENT_COUNTER(m6803.extra_cycles);
m6803.extra_cycles = 0;
@ -840,6 +846,8 @@ int hd63701_execute(int cycles)
INCREMENT_COUNTER(hd63701.extra_cycles);
hd63701.extra_cycles = 0;
end_run = 0;
do
{
if( hd63701.wai_state & (HD63701_WAI|HD63701_SLP) )
@ -855,7 +863,7 @@ int hd63701_execute(int cycles)
(*hd63701.insn[ireg])();
INCREMENT_COUNTER(cycles_63701[ireg]);
}
} while( m6800_ICount>0 );
} while( m6800_ICount>0 && !end_run );
INCREMENT_COUNTER(hd63701.extra_cycles);
hd63701.extra_cycles = 0;
@ -905,6 +913,8 @@ void nsc8105_init()
m6800.cycles = cycles_nsc8105;
//state_register("nsc8105", index);
}
/****************************************************************************
* Execute cycles CPU cycles. Return number of cycles really executed
****************************************************************************/
@ -919,6 +929,8 @@ int nsc8105_execute(int cycles)
INCREMENT_COUNTER(nsc8105.extra_cycles);
nsc8105.extra_cycles = 0;
end_run = 0;
do
{
if( nsc8105.wai_state & NSC8105_WAI )
@ -934,7 +946,7 @@ int nsc8105_execute(int cycles)
(*nsc8105.insn[ireg])();
INCREMENT_COUNTER(cycles_nsc8105[ireg]);
}
} while( m6800_ICount>0 );
} while( m6800_ICount>0 && !end_run );
INCREMENT_COUNTER(nsc8105.extra_cycles);
nsc8105.extra_cycles = 0;
@ -953,7 +965,7 @@ void M6800RunEnd()
if (!DebugCPU_M6800Initted) bprintf(PRINT_ERROR, _T("M6800RunEnd called without init\n"));
#endif
m6800_ICount = 0;
end_run = 1;
}
#if (HAS_M6803||HAS_HD63701)

View File

@ -62,6 +62,7 @@ typedef struct
INT32 irq_state[9]; /* KW Additional lines for HD63705 */
INT32 nmi_state;
INT32 nTotalCycles;
INT32 end_run;
int (*irq_callback)(int irqline);
} m6805_Regs;
@ -476,6 +477,8 @@ int m6805Run(int cycles)
m6805_ICount = cycles;
S = SP_ADJUST( S ); /* Taken from CPU_SET_CONTEXT when pointer'afying */
m6805.end_run = 0;
do
{
if (m6805.pending_interrupts != 0)
@ -757,7 +760,7 @@ int m6805Run(int cycles)
}
m6805_ICount -= cycles1[ireg];
m6805.nTotalCycles += cycles1[ireg];
} while( m6805_ICount > 0 );
} while( m6805_ICount > 0 && !m6805.end_run);
return cycles - m6805_ICount;
}
@ -775,7 +778,7 @@ void m6805RunEnd()
if (!DebugCPU_M6805Initted) bprintf(PRINT_ERROR, _T("m6805RunEnd called without init\n"));
#endif
m6805_ICount = 0;
m6805.end_run = 1;
}
void m6805NewFrame()
@ -793,7 +796,7 @@ int m6805TotalCycles()
if (!DebugCPU_M6805Initted) bprintf(PRINT_ERROR, _T("m6805TotalCycles called without init\n"));
#endif
return m6805.nTotalCycles;
return m6805.nTotalCycles; // segment cycles taken care of! (search nTotalCycles)
}
int m6805Scan(int nAction)

View File

@ -410,6 +410,7 @@ int nec_execute(int cycles)
nec_state->icount = cycles;
nec_state->cycles_remaining = cycles;
nec_state->stop_run = 0;
if (nec_state->halted)
{
@ -438,11 +439,11 @@ int nec_execute(int cycles)
do_prefetch(nec_state, prev_ICount);
}
nec_state->cycles_total += cycles - nec_state->icount;
nec_state->cycles_remaining = 0;
nec_state->stop_run = 0;
cycles = cycles - nec_state->icount;
nec_state->cycles_total += cycles;
nec_state->cycles_remaining = nec_state->icount = 0;
return (cycles - nec_state->icount);
return cycles;
}
void necInit(int cpu, int type)

View File

@ -519,6 +519,7 @@ int v25_execute(int cycles)
nec_state->icount = cycles;
nec_state->cycles_remaining = cycles;
nec_state->stop_run = 0;
while(nec_state->icount>0 && !nec_state->stop_run) {
/* Dispatch IRQ */
@ -555,10 +556,11 @@ int v25_execute(int cycles)
}
}
nec_state->stop_run = 0;
nec_state->cycles_total += cycles - nec_state->icount;
cycles = cycles - nec_state->icount;
nec_state->cycles_total += cycles;
nec_state->icount = nec_state->cycles_remaining = 0;
return cycles - nec_state->icount;
return cycles;
}
void v25Init(int cpu, int type, int clock)

View File

@ -104,6 +104,7 @@ typedef struct
PAIR opcode;
UINT8 internalram[8];
UINT32 total_cycles;
INT32 end_run;
} pic16C5x_Regs;
static pic16C5x_Regs R;
@ -833,7 +834,8 @@ int pic16c5xRun(int cycles)
UINT8 T0_in;
slice_cycles = cycles;
pic16C5x_icount = cycles;
R.end_run = 0;
do
{
if (PD == 0) /* Sleep Mode */
@ -891,15 +893,15 @@ int pic16c5xRun(int cycles)
pic16C5x_icount -= inst_cycles;
} while (pic16C5x_icount>0);
} while (pic16C5x_icount>0 && !R.end_run);
INT32 ret = cycles - pic16C5x_icount;
cycles = cycles - pic16C5x_icount;
R.total_cycles += ret;
R.total_cycles += cycles;
slice_cycles = 0;
pic16C5x_icount = 0;
return ret;
return cycles;
}
@ -1002,7 +1004,7 @@ void pic16c5xNewFrame()
void pic16c5xRunEnd()
{
pic16C5x_icount = 0;
R.end_run = 1;
}
INT32 pic16c5xIdle(INT32 cycles)

View File

@ -51,6 +51,8 @@ typedef struct {
UINT16 ras[8]; /* 8 return address stack entries */
UINT8 irq_state;
UINT32 total_cycles;
INT32 end_run;
} s2650_Regs;
static s2650_Regs S;
@ -860,6 +862,8 @@ int s2650Run(int cycles)
s2650_ICount = cycles_slice = cycles;
S.end_run = 0;
do
{
S.ppc = S.page + S.iar;
@ -1462,7 +1466,7 @@ int s2650Run(int cycles)
M_BRA( --S.reg[S.r] );
break;
}
} while( s2650_ICount > 0 );
} while( s2650_ICount > 0 && !S.end_run );
INT32 ret = cycles - s2650_ICount;
@ -1486,7 +1490,7 @@ void s2650NewFrame()
void s2650RunEnd()
{
s2650_ICount = 0;
S.end_run = 1;
}
INT32 s2650Idle(INT32 cycles)

View File

@ -37,8 +37,6 @@ extern INT32 s2650_get_pc();
static void core_set_irq(INT32 cpu, INT32 line, INT32 state)
{
return; // iq_132
INT32 active = nActiveS2650;
if (active != cpu)
{
@ -46,6 +44,7 @@ return; // iq_132
s2650Open(cpu);
}
s2650SetIRQLine(line, state);
if (active != cpu)
{

View File

@ -117,6 +117,7 @@ typedef struct
INT32 sh2_icount;
INT32 sh2_total_cycles; // used externally (drivers/etc)
INT32 sh2_eat_cycles;
INT32 end_run;
int (*irq_callback)(int irqline);
} SH2;
@ -3275,6 +3276,7 @@ int Sh2Run(int cycles)
sh2->sh2_icount = cycles;
sh2->sh2_cycles_to_run = cycles;
sh2->end_run = 0;
do
{
@ -3328,7 +3330,7 @@ int Sh2Run(int cycles)
sh2->sh2_total_cycles++;
sh2->sh2_icount -= sh2->sh2_eat_cycles;
// timer check
// timer check
{
unsigned int cy = sh2_GetTotalCycles();
@ -3341,20 +3343,22 @@ int Sh2Run(int cycles)
if (sh2->dma_timer_active[1])
if ((cy - sh2->dma_timer_base[1]) >= sh2->dma_timer_cycles[1])
sh2_dmac_callback(1);
if ( sh2->timer_active )
if ((cy - sh2->timer_base) >= sh2->timer_cycles)
sh2_timer_callback();
}
} while( sh2->sh2_icount > 0 );
sh2->cycle_counts += cycles - (UINT32)sh2->sh2_icount;
sh2->sh2_cycles_to_run = sh2->sh2_icount;
} while( sh2->sh2_icount > 0 && !sh2->end_run );
return cycles - sh2->sh2_icount;
cycles = cycles - sh2->sh2_icount;
sh2->cycle_counts += cycles;
sh2->sh2_cycles_to_run = sh2->sh2_icount = 0;
return cycles;
}
static void Sh2SetIRQLine_Internal(const int line, const int state)
@ -3430,9 +3434,7 @@ void Sh2StopRun()
if (!DebugCPU_SH2Initted) bprintf(PRINT_ERROR, _T("Sh2StopRun called without init\n"));
#endif
sh2->sh2_total_cycles += sh2->sh2_icount;
sh2->sh2_icount = 0;
sh2->sh2_cycles_to_run = 0;
sh2->end_run = 1;
}
INT32 Sh2TotalCycles()

View File

@ -2051,13 +2051,12 @@ INT32 tlcs90Run(INT32 nCycles)
} while( cpustate->icount > 0 && cpustate->run_end == 0 );
cpustate->total_cycles += cpustate->nCycles - cpustate->icount;
INT32 ret = cpustate->nCycles - cpustate->icount;
nCycles = cpustate->nCycles - cpustate->icount;
cpustate->total_cycles += nCycles;
cpustate->nCycles = cpustate->icount = 0;
return ret;
return nCycles;
}
INT32 tlcs90Idle(INT32 cycles)

View File

@ -860,7 +860,7 @@ int tms32010_Ext_IRQ(void)
return (0*CLK);
}
static INT32 end_run = 0;
/****************************************************************************
* Execute IPeriod. Return 0 if emulation should be stopped
@ -868,9 +868,10 @@ int tms32010_Ext_IRQ(void)
int tms32010_execute(int cycles)
{
tms32010_icount = cycles;
tms32010_current_cycles = cycles;
end_run = 0;
do
{
if (R.INTF) {
@ -894,12 +895,15 @@ int tms32010_execute(int cycles)
tms32010_icount -= cycles_7F_other[(R.opcode.b.l & 0x1f)];
(*(opcode_7F_other[(R.opcode.b.l & 0x1f)]))();
}
} while (tms32010_icount>0);
} while (tms32010_icount>0 && !end_run);
cycles = cycles - tms32010_icount;
tms32010_cycles += cycles;
tms32010_current_cycles = 0;
tms32010_cycles += cycles - tms32010_icount;
tms32010_icount = 0;
return cycles - tms32010_icount;
return cycles;
}
UINT32 tms32010TotalCycles()
@ -914,7 +918,7 @@ void tms32010NewFrame()
void tms32010RunEnd()
{
tms32010_icount = 0;
end_run = 1;
}
void tms32010_scan(INT32 nAction)