fix extended attributes in newppu better, and fix old ppu's chr banking to match newppu maybe?

This commit is contained in:
zeromus 2017-04-29 23:03:35 +00:00
parent f3afacc5aa
commit 9f104fc38c
3 changed files with 17 additions and 18 deletions

View File

@ -27,6 +27,7 @@
#define SpriteON (PPU[1] & 0x10) //Show Sprite
#define ScreenON (PPU[1] & 0x08) //Show screen
#define PPUON (PPU[1] & 0x18) //PPU should operate
#define Sprite16 (PPU[0] & 0x20) //Sprites 8x16/8x8
static void (*sfun)(int P);
static void (*psfun)(void);
@ -113,9 +114,9 @@ typedef struct __cartdata {
uint8 size;
} cartdata;
#define Sprite16 (PPU[0]& 0x20) //Sprites 8x16/8x8
//#define MMC5SPRVRAMADR(V) &MMC5SPRVPage[(V)>>10][(V)]
static inline uint8 * MMC5BGVRAMADR(uint32 A) {
uint8* MMC5BGVRAMADR(uint32 A)
{
if(Sprite16)
{
bool isPattern = PPUON;
@ -235,12 +236,20 @@ uint8 FASTCALL mmc5_PPURead(uint32 A)
return ExRAM[A & 0x3FF];
}
}
if (MMC5HackCHRMode == 1)
{
if((A&0x3FF)>=0x3C0)
{
return ExRAM[NTRefreshAddr & 0x3ff];
uint8 byte = ExRAM[NTRefreshAddr & 0x3ff];
//get attribute part
byte >>= 6;
//adjust it to the right position within the byte
int x = NTRefreshAddr&31;
int y = NTRefreshAddr>>5;
if(y&2) byte <<= 4;
if(x&2) byte <<= 2;
return byte;
}
}

View File

@ -374,18 +374,7 @@ uint8 UPALRAM[0x03];//for 0x4/0x8/0xC addresses in palette, the ones in
#define MMC5SPRVRAMADR(V) &MMC5SPRVPage[(V) >> 10][(V)]
#define VRAMADR(V) &VPage[(V) >> 10][(V)]
//mbg 8/6/08 - fix a bug relating to
//"When in 8x8 sprite mode, only one set is used for both BG and sprites."
//in mmc5 docs
uint8 * MMC5BGVRAMADR(uint32 V) {
if (!Sprite16) {
extern uint8 mmc5ABMode; /* A=0, B=1 */
if (mmc5ABMode == 0)
return MMC5SPRVRAMADR(V);
else
return &MMC5BGVPage[(V) >> 10][(V)];
} else return &MMC5BGVPage[(V) >> 10][(V)];
}
extern uint8* MMC5BGVRAMADR(uint32 A);
//this duplicates logic which is embedded in the ppu rendering code
//which figures out where to get CHR data from depending on various hack modes
@ -500,7 +489,7 @@ void (*FFCEUX_PPUWrite)(uint32 A, uint8 V) = 0;
#define CALL_PPUWRITE(A, V) (FFCEUX_PPUWrite ? FFCEUX_PPUWrite(A, V) : FFCEUX_PPUWrite_Default(A, V))
//whether to use the new ppu (new PPU doesn't handle MMC5 extra nametables at all
//whether to use the new ppu
int newppu = 0;
void ppu_getScroll(int &xpos, int &ypos) {

View File

@ -22,6 +22,7 @@ void FCEUPPU_SaveState(void);
void FCEUPPU_LoadState(int version);
uint32 FCEUPPU_PeekAddress();
uint8* FCEUPPU_GetCHR(uint32 vadr, uint32 refreshaddr);
int FCEUPPU_GetAttr(int ntnum, int xt, int yt);
void ppu_getScroll(int &xpos, int &ypos);