games/snes: cpu timing fix
This commit is contained in:
parent
b13425e2b0
commit
0d080855b2
|
@ -609,11 +609,8 @@ enum { COP = 0, BRK = 1, NMI = 3, IRQ = 5 };
|
|||
static void
|
||||
interrupt(int src)
|
||||
{
|
||||
if(src > BRK){
|
||||
io();
|
||||
if(!emu)
|
||||
io();
|
||||
}
|
||||
if(src > BRK)
|
||||
memread(pc | rPB);
|
||||
if(!emu)
|
||||
push8(rPB >> 16);
|
||||
push16(pc);
|
||||
|
@ -687,7 +684,6 @@ cpustep(void)
|
|||
lastpc = curpc;
|
||||
if(trace)
|
||||
print("%.6x %.2x A=%.4x X=%.4x Y=%.4x P=%.2x %.2x\n", curpc, op, rA, rX, rY, rP, rS);
|
||||
cyc = 0;
|
||||
switch(op){
|
||||
case 0x00: fetch8(); interrupt(BRK); break;
|
||||
case 0x01: nz(rA |= mem816(dpi(0, 1, 0), 0)); break;
|
||||
|
|
|
@ -24,7 +24,7 @@ extern u16int spc;
|
|||
extern u8int dspstate;
|
||||
extern u16int dspcounter, noise;
|
||||
|
||||
extern int ppuclock, spcclock, dspclock, stimerclock;
|
||||
extern int ppuclock, spcclock, dspclock, stimerclock, cpupause;
|
||||
extern int battery, saveclock, scale, mouse;
|
||||
|
||||
enum {
|
||||
|
|
|
@ -183,7 +183,7 @@ regread(u16int p)
|
|||
reg[OPCTLATCH] &= ~3;
|
||||
return mdr2 = reg[p] | v | mdr2 & 0x20;
|
||||
case 0x2180:
|
||||
v = memread(0x7e0000 | reg[0x2181] | reg[0x2182] << 8 | (reg[0x2183] & 1) << 16);
|
||||
v = mem[reg[0x2181] | reg[0x2182] << 8 | (reg[0x2183] & 1) << 16];
|
||||
incwram();
|
||||
return v;
|
||||
case 0x4016:
|
||||
|
@ -337,7 +337,7 @@ regwrite(u16int p, u8int v)
|
|||
case 0x213e:
|
||||
return;
|
||||
case 0x2180:
|
||||
memwrite(0x7e0000 | reg[0x2181] | reg[0x2182] << 8 | (reg[0x2183] & 1) << 16, v);
|
||||
mem[reg[0x2181] | reg[0x2182] << 8 | (reg[0x2183] & 1) << 16] = v;
|
||||
incwram();
|
||||
return;
|
||||
case 0x4016:
|
||||
|
|
|
@ -857,9 +857,11 @@ ppustep(void)
|
|||
pixeldraw(rx, ppuy - 1, ppuy >= yvbl ? 0x31c8 : 0);
|
||||
}
|
||||
|
||||
if(ppux == 134)
|
||||
cpupause = 1;
|
||||
if(ppux == 0x116 && ppuy <= yvbl)
|
||||
hdma |= reg[0x420c];
|
||||
if((reg[NMITIMEN] & HCNTIRQ) != 0 && htime == ppux && ((reg[NMITIMEN] & VCNTIRQ) == 0 || vtime == ppuy))
|
||||
if((reg[NMITIMEN] & HCNTIRQ) != 0 && htime+4 == ppux && ((reg[NMITIMEN] & VCNTIRQ) == 0 || vtime == ppuy))
|
||||
irq |= IRQPPU;
|
||||
if(++ppux >= 340){
|
||||
ppux = 0;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
uchar *prg, *sram;
|
||||
int nprg, nsram, hirom, battery;
|
||||
|
||||
int ppuclock, spcclock, dspclock, stimerclock, saveclock, msgclock, paused, perfclock;
|
||||
int ppuclock, spcclock, dspclock, stimerclock, saveclock, msgclock, paused, perfclock, cpupause;
|
||||
Mousectl *mc;
|
||||
QLock pauselock;
|
||||
u32int keys;
|
||||
|
@ -267,7 +267,11 @@ usage:
|
|||
qlock(&pauselock);
|
||||
qunlock(&pauselock);
|
||||
}
|
||||
t = cpustep();
|
||||
if(cpupause){
|
||||
t = 40;
|
||||
cpupause = 0;
|
||||
}else
|
||||
t = cpustep();
|
||||
spcclock -= t;
|
||||
stimerclock += t;
|
||||
ppuclock += t;
|
||||
|
|
Loading…
Reference in a new issue