Added cpu ignore in ppu_run for page crossing and irqs, if these happens during the cpu runtime the counter is added to in ppu_run we check for it, if there is an ignore, we wont run the cpu_run to make up the time the ppu was running when those page crossings/whatever happened, also added correct PAL vblank time

This commit is contained in:
qeed 2009-06-24 19:01:03 +00:00
parent 83623cc9b9
commit e0028f6b17
2 changed files with 46 additions and 16 deletions

View File

@ -100,12 +100,13 @@ struct BITREVLUT {
};
BITREVLUT<uint8,8> bitrevlut;
int cpu_ignore;
struct PPUSTATUS
{
int cycle, end_cycle;
int sl;
int cycle, end_cycle;
};
struct SPRITE_READ
{
int num;
@ -2008,6 +2009,17 @@ void runppu(int x) {
//if(cputodo<200) return;
ppur.status.cycle = (ppur.status.cycle + x) %
ppur.status.end_cycle;
if (cpu_ignore)
{
if (cpu_ignore <= x)
{
cpu_ignore = 0;
X6502_Run(x-cpu_ignore);
}
else
cpu_ignore -= x;
}
else
X6502_Run(x);
//pputime -= cputodo<<2;
}
@ -2071,8 +2083,10 @@ int FCEUX_PPU_Loop(int skip) {
else
runppu(20*kLineTime);
ppur.status.sl = 0;
cpu_ignore = 0;
runppu(242*kLineTime);
ppudead = 0;
cpu_ignore = 0;
goto finish;
}
@ -2090,7 +2104,12 @@ int FCEUX_PPU_Loop(int skip) {
runppu(delay); //X6502_Run(12);
if(VBlankON) TriggerNMI();
if (PAL)
runppu(70*(kLineTime)-delay);
else
runppu(20*(kLineTime)-delay);
cpu_ignore = 0; //no ignores because NMI runs full cycle
//this seems to run just before the dummy scanline begins
PPU_status = 0;
//this early out caused metroid to fail to boot. I am leaving it here as a reminder of what not to do
@ -2397,6 +2416,7 @@ int FCEUX_PPU_Loop(int skip) {
//idle for one line
runppu(kLineTime);
cpu_ignore = 0;
framectr++;
}

View File

@ -29,7 +29,8 @@
#endif
#include "x6502abbrev.h"
extern int newppu;
extern int cpu_ignore;
X6502 X;
uint32 timestamp;
void (*MapIRQHook)(int a);
@ -42,6 +43,15 @@ void (*MapIRQHook)(int a);
timestamp+=__x; \
}
#define XADDCYC(x) \
{ \
int __x=x; \
_tcount+=__x; \
_count-=__x*48; \
timestamp+=__x; \
if (newppu) cpu_ignore += x; \
}
//normal memory read
static INLINE uint8 RdMem(unsigned int A)
{
@ -111,11 +121,11 @@ static uint8 ZNTable[256];
int32 disp; \
disp=(int8)RdMem(_PC); \
_PC++; \
ADDCYC(1); \
XADDCYC(1); \
tmp=_PC; \
_PC+=disp; \
if((tmp^_PC)&0x100) \
ADDCYC(1); \
XADDCYC(1); \
} \
else _PC++; \
}
@ -220,7 +230,7 @@ static uint8 ZNTable[256];
{ \
target&=0xFFFF; \
RdMem(target^0x100); \
ADDCYC(1); \
XADDCYC(1); \
} \
}
@ -277,7 +287,7 @@ static uint8 ZNTable[256];
{ \
target&=0xFFFF; \
RdMem(target^0x100); \
ADDCYC(1); \
XADDCYC(1); \
} \
}
@ -445,7 +455,7 @@ extern int test; test++;
{
if(!_jammed)
{
ADDCYC(7);
XADDCYC(7);
PUSH(_PC>>8);
PUSH(_PC);
PUSH((_P&~B_FLAG)|(U_FLAG));
@ -460,7 +470,7 @@ extern int test; test++;
{
if(!(_PI&I_FLAG) && !_jammed)
{
ADDCYC(7);
XADDCYC(7);
PUSH(_PC>>8);
PUSH(_PC);
PUSH((_P&~B_FLAG)|(U_FLAG));