From 621cc8e2605ae117ccb28b6599d454fe2c92857a Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 8 Dec 2009 05:54:21 +0000 Subject: [PATCH] fix ntview for new ppu? [[Split portion of a mixed commit.]] --- src/drivers/win/ntview.cpp | 4 +--- src/ppu.cpp | 17 +++++++++++++++++ src/ppu.h | 2 ++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/drivers/win/ntview.cpp b/src/drivers/win/ntview.cpp index 7a63f78e..4c568f46 100644 --- a/src/drivers/win/ntview.cpp +++ b/src/drivers/win/ntview.cpp @@ -299,10 +299,8 @@ void FCEUD_UpdateNTView(int scanline, bool drawall) { //uint8 *pbitmap = ppuv_palette; if (!hNTView) return; - xpos = ((RefreshAddr & 0x400) >> 2) | ((RefreshAddr & 0x1F) << 3) | XOffset; + ppu_getScroll(xpos,ypos); - ypos = ((RefreshAddr & 0x3E0) >> 2) | ((RefreshAddr & 0x7000) >> 12); - if(RefreshAddr & 0x800) ypos += 240; //char str[50]; //sprintf(str,"%d,%d,%d",horzscroll,vertscroll,ntmirroring); diff --git a/src/ppu.cpp b/src/ppu.cpp index cded0ae9..dcd15064 100644 --- a/src/ppu.cpp +++ b/src/ppu.cpp @@ -266,6 +266,7 @@ struct PPUREGS { } } ppur; + static void makeppulut(void) { int x; @@ -471,6 +472,22 @@ void (*FFCEUX_PPUWrite)(uint32 A, uint8 V) = 0; //whether to use the new ppu (new PPU doesn't handle MMC5 extra nametables at all int newppu = 0; + +void ppu_getScroll(int &xpos, int &ypos) +{ + if(newppu) + { + ypos = ppur._vt*8 + ppur._fv + ppur._v*256; + xpos = ppur._ht*8 + ppur.fh + ppur._h*256; + } + else + { + xpos = ((RefreshAddr & 0x400) >> 2) | ((RefreshAddr & 0x1F) << 3) | XOffset; + + ypos = ((RefreshAddr & 0x3E0) >> 2) | ((RefreshAddr & 0x7000) >> 12); + if(RefreshAddr & 0x800) ypos += 240; + } +} //--------------- static DECLFR(A2002) diff --git a/src/ppu.h b/src/ppu.h index d2f519cd..0e15114d 100644 --- a/src/ppu.h +++ b/src/ppu.h @@ -17,6 +17,8 @@ extern uint8 PPUCHRRAM; void FCEUPPU_SaveState(void); void FCEUPPU_LoadState(int version); uint8* FCEUPPU_GetCHR(uint32 vadr, uint32 refreshaddr); +void ppu_getScroll(int &xpos, int &ypos); + #ifdef _MSC_VER #define FASTCALL __fastcall