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:
parent
83623cc9b9
commit
e0028f6b17
36
src/ppu.cpp
36
src/ppu.cpp
|
@ -100,12 +100,13 @@ struct BITREVLUT {
|
|||
};
|
||||
BITREVLUT<uint8,8> bitrevlut;
|
||||
|
||||
struct PPUSTATUS
|
||||
{
|
||||
int cycle, end_cycle;
|
||||
int sl;
|
||||
};
|
||||
int cpu_ignore;
|
||||
|
||||
struct PPUSTATUS
|
||||
{
|
||||
int sl;
|
||||
int cycle, end_cycle;
|
||||
};
|
||||
struct SPRITE_READ
|
||||
{
|
||||
int num;
|
||||
|
@ -139,7 +140,7 @@ struct PPUREGS {
|
|||
: fv(0), v(0), h(0), vt(0), ht(0), fh(0), s(0), par(0), ar(0)
|
||||
, _fv(0), _v(0), _h(0), _vt(0), _ht(0)
|
||||
{ status.cycle = 0; status.end_cycle = 341;
|
||||
status.sl = 241;
|
||||
status.sl = 241;
|
||||
}
|
||||
|
||||
void install_latches() {
|
||||
|
@ -2008,7 +2009,18 @@ void runppu(int x) {
|
|||
//if(cputodo<200) return;
|
||||
ppur.status.cycle = (ppur.status.cycle + x) %
|
||||
ppur.status.end_cycle;
|
||||
X6502_Run(x);
|
||||
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();
|
||||
runppu(20*(kLineTime)-delay);
|
||||
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++;
|
||||
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
@ -574,4 +584,4 @@ const uint8 optype[256] = {
|
|||
/*0xD0*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0,
|
||||
/*0xE0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0,
|
||||
/*0xF0*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue