* PPU Viewer: added "Mask unused graphics" and "Invert the mask" checkboxes

* PPU Viewer: fixed window layout when using big fonts
This commit is contained in:
ansstuff 2013-09-16 16:04:11 +00:00
parent 1399397477
commit 1ab0323d64
8 changed files with 413 additions and 288 deletions

View File

@ -92,7 +92,9 @@ extern unsigned int MemView_HighlightActivity_FadingPeriod;
extern bool MemView_HighlightActivity_FadeWhenPaused;
extern int MemFind_wndx, MemFind_wndy;
extern int NTViewPosX,NTViewPosY;
extern int PPUViewPosX,PPUViewPosY;
extern int PPUViewPosX, PPUViewPosY;
extern bool PPUView_maskUnusedGraphics;
extern bool PPUView_invertTheMask;
extern int MainWindow_wndx, MainWindow_wndy;
extern int MemWatch_wndx, MemWatch_wndy;
extern int Monitor_wndx, Monitor_wndy;
@ -301,6 +303,8 @@ static CFGSTRUCT fceuconfig[] =
AC(NTViewPosY),
AC(PPUViewPosX),
AC(PPUViewPosY),
AC(PPUView_maskUnusedGraphics),
AC(PPUView_invertTheMask),
AC(MainWindow_wndx),
AC(MainWindow_wndy),
AC(MemWatch_wndx),

View File

@ -2090,7 +2090,8 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
case IDC_DEBUGGER_BOOKMARK_NAME: NameDebuggerBookmark(hwndDlg); break;
case IDC_DEBUGGER_ENABLE_SYMBOLIC:
{
symbDebugEnabled = IsDlgButtonChecked(hwndDlg, IDC_DEBUGGER_ENABLE_SYMBOLIC);
symbDebugEnabled ^= 1;
CheckDlgButton(hwndDlg, IDC_DEBUGGER_ENABLE_SYMBOLIC, symbDebugEnabled ? BST_CHECKED : BST_UNCHECKED);
UpdateDebugger(false);
break;
}

View File

@ -19,6 +19,7 @@
*/
#include "common.h"
#include "ppuview.h"
#include "../../palette.h"
#include "../../fceu.h"
#include "../../cart.h"
@ -28,34 +29,42 @@ HWND hPPUView;
extern uint8 *VPage[8];
extern uint8 PALRAM[0x20];
int PPUViewPosX,PPUViewPosY;
int PPUViewPosX, PPUViewPosY;
bool PPUView_maskUnusedGraphics = true;
bool PPUView_invertTheMask = false;
uint8 palcache[32] = { 0xFF }; //palette cache
uint8 chrcache0[0x1000],chrcache1[0x1000],logcache0[0x1000],logcache1[0x1000]; //cache CHR, fixes a refresh problem when right-clicking
uint8 *pattern0,*pattern1; //pattern table bitmap arrays
uint8 chrcache0[0x1000], chrcache1[0x1000], logcache0[0x1000], logcache1[0x1000]; //cache CHR, fixes a refresh problem when right-clicking
uint8 *pattern0, *pattern1; //pattern table bitmap arrays
uint8 *ppuv_palette;
static int pindex0=0,pindex1=0;
int PPUViewScanline=0,PPUViewer=0;
static int pindex0 = 0, pindex1 = 0;
int PPUViewScanline = 0, PPUViewer = 0;
int PPUViewSkip;
int PPUViewRefresh = 15;
int mouse_x,mouse_y;
int mouse_x, mouse_y;
#define PATTERNWIDTH 128
#define PATTERNHEIGHT 128
#define PATTERNBITWIDTH PATTERNWIDTH*3
#define PATTERNDESTX 10
#define PATTERNDESTY 15
#define PATTERNDESTX_BASE 7
#define PATTERNDESTY_BASE 16
#define ZOOM 2
#define PALETTEWIDTH 32*4*4
#define PALETTEHEIGHT 32*2
#define PALETTEBITWIDTH PALETTEWIDTH*3
#define PALETTEDESTX 10
#define PALETTEDESTY 327
#define PALETTEDESTX_BASE 7
#define PALETTEDESTY_BASE 16
#define TBM_SETPOS (WM_USER+5)
#define TBM_SETRANGE (WM_USER+6)
#define TBM_GETPOS (WM_USER)
int patternDestX = PATTERNDESTX_BASE;
int patternDestY = PATTERNDESTY_BASE;
int paletteDestX = PALETTEDESTX_BASE;
int paletteDestY = PALETTEDESTY_BASE;
BITMAPINFO bmInfo;
HDC pDC,TmpDC0,TmpDC1;
HBITMAP TmpBmp0,TmpBmp1;
@ -67,151 +76,172 @@ HBITMAP TmpBmp2,TmpBmp3;
HGDIOBJ TmpObj2,TmpObj3;
void PPUViewDoBlit() {
if(!hPPUView) return;
if(PPUViewSkip < PPUViewRefresh) {
PPUViewSkip++;
return;
}
PPUViewSkip=0;
void PPUViewDoBlit()
{
if (!hPPUView)
return;
if (PPUViewSkip < PPUViewRefresh)
{
PPUViewSkip++;
return;
}
PPUViewSkip = 0;
StretchBlt(pDC,PATTERNDESTX,PATTERNDESTY,PATTERNWIDTH*ZOOM,PATTERNHEIGHT*ZOOM,TmpDC0,0,PATTERNHEIGHT-1,PATTERNWIDTH,-PATTERNHEIGHT,SRCCOPY);
StretchBlt(pDC,PATTERNDESTX+(PATTERNWIDTH*ZOOM)+1,PATTERNDESTY,PATTERNWIDTH*ZOOM,PATTERNHEIGHT*ZOOM,TmpDC1,0,PATTERNHEIGHT-1,PATTERNWIDTH,-PATTERNHEIGHT,SRCCOPY);
StretchBlt(pDC,PALETTEDESTX,PALETTEDESTY,PALETTEWIDTH,PALETTEHEIGHT,TmpDC2,0,PALETTEHEIGHT-1,PALETTEWIDTH,-PALETTEHEIGHT,SRCCOPY);
StretchBlt(pDC, patternDestX, patternDestY, PATTERNWIDTH * ZOOM, PATTERNHEIGHT * ZOOM, TmpDC0, 0, PATTERNHEIGHT - 1, PATTERNWIDTH, -PATTERNHEIGHT, SRCCOPY);
StretchBlt(pDC, patternDestX + (PATTERNWIDTH * ZOOM) + 1, patternDestY, PATTERNWIDTH * ZOOM, PATTERNHEIGHT * ZOOM, TmpDC1, 0, PATTERNHEIGHT - 1, PATTERNWIDTH, -PATTERNHEIGHT, SRCCOPY);
StretchBlt(pDC, paletteDestX, paletteDestY, PALETTEWIDTH, PALETTEHEIGHT, TmpDC2, 0, PALETTEHEIGHT - 1, PALETTEWIDTH, -PALETTEHEIGHT, SRCCOPY);
}
//---------CDLogger VROM
extern unsigned char *cdloggervdata;
extern unsigned int cdloggerVideoDataSize;
extern int debug_loggingCD;
void DrawPatternTable(uint8 *bitmap, uint8 *table, uint8 *log, uint8 pal) {
int i,j,x,y,index=0;
int p=0,tmp;
uint8 chr0,chr1,logs;
uint8 *pbitmap = bitmap;
void DrawPatternTable(uint8 *bitmap, uint8 *table, uint8 *log, uint8 pal)
{
int i,j,x,y,index=0;
int p=0,tmp;
uint8 chr0,chr1,logs;
uint8 *pbitmap = bitmap;
pal <<= 2;
for (i = 0; i < 16; i++) //Columns
{
for (j = 0; j < 16; j++) //Rows
{
//-----------------------------------------------
///8x8 sprite
for (y = 0; y < 8; y++)
{
chr0 = table[index];
chr1 = table[index + 8];
logs = log[index] & log[index + 8];
tmp = 7;
if(debug_loggingCD && cdloggerVideoDataSize && ((logs & 3) == 0)) {
for (x = 0; x < 8; x++)
{
p = (chr0 >> tmp) & 1;
p |= ((chr1 >> tmp) & 1) << 1;
p = palcache[p | pal];
tmp--;
*(uint8*)(pbitmap++) = palo[p].b >> 2;
*(uint8*)(pbitmap++) = palo[p].g >> 2;
*(uint8*)(pbitmap++) = palo[p].r >> 2;
}
} else {
for (x = 0; x < 8; x++)
{
p = (chr0 >> tmp) & 1;
p |= ((chr1 >> tmp) & 1) << 1;
p = palcache[p | pal];
tmp--;
*(uint8*)(pbitmap++) = palo[p].b;
*(uint8*)(pbitmap++) = palo[p].g;
*(uint8*)(pbitmap++) = palo[p].r;
}
}
index++;
pbitmap += ((PALETTEBITWIDTH>>2)-24);
}
//------------------------------------------------
index+=8;
pbitmap -= (((PALETTEBITWIDTH>>2)<<3)-24);
}
pbitmap += ((PALETTEBITWIDTH>>2)*7);
pal <<= 2;
for (i = 0; i < 16; i++) //Columns
{
for (j = 0; j < 16; j++) //Rows
{
//-----------------------------------------------
// 8x8 sprite
for (y = 0; y < 8; y++)
{
chr0 = table[index];
chr1 = table[index + 8];
logs = log[index] & log[index + 8];
tmp = 7;
if (PPUView_maskUnusedGraphics && cdloggerVideoDataSize && ((bool)(logs & 3) == PPUView_invertTheMask))
{
// draw pixel ~8x darker
for (x = 0; x < 8; x++)
{
p = (chr0 >> tmp) & 1;
p |= ((chr1 >> tmp) & 1) << 1;
p = palcache[p | pal];
tmp--;
*(uint8*)(pbitmap++) = palo[p].b >> 3;
*(uint8*)(pbitmap++) = palo[p].g >> 3;
*(uint8*)(pbitmap++) = palo[p].r >> 3;
}
} else
{
for (x = 0; x < 8; x++)
{
p = (chr0 >> tmp) & 1;
p |= ((chr1 >> tmp) & 1) << 1;
p = palcache[p | pal];
tmp--;
*(uint8*)(pbitmap++) = palo[p].b;
*(uint8*)(pbitmap++) = palo[p].g;
*(uint8*)(pbitmap++) = palo[p].r;
}
}
index++;
pbitmap += ((PALETTEBITWIDTH>>2)-24);
}
//------------------------------------------------
index+=8;
pbitmap -= (((PALETTEBITWIDTH>>2)<<3)-24);
}
pbitmap += ((PALETTEBITWIDTH>>2)*7);
}
}
void FCEUD_UpdatePPUView(int scanline, int refreshchr) {
if(!PPUViewer) return;
if(scanline != -1 && scanline != PPUViewScanline) return;
void FCEUD_UpdatePPUView(int scanline, int refreshchr)
{
if(!PPUViewer) return;
if(scanline != -1 && scanline != PPUViewScanline) return;
int x,y,i;
uint8 *pbitmap = ppuv_palette;
int x,y,i;
uint8 *pbitmap = ppuv_palette;
if(!hPPUView) return;
if(PPUViewSkip < PPUViewRefresh) return;
if(!hPPUView) return;
if(PPUViewSkip < PPUViewRefresh) return;
if(refreshchr) {
for (i = 0, x=0x1000; i < 0x1000; i++, x++) {
chrcache0[i] = VPage[i>>10][i];
chrcache1[i] = VPage[x>>10][x];
if(debug_loggingCD && cdloggerVideoDataSize) {
int addr;
addr = &VPage[i >> 10][i] - CHRptr[0];
if ((addr >= 0) && (addr < (int)cdloggerVideoDataSize))
logcache0[i] = cdloggervdata[addr];
addr = &VPage[x >> 10][x] - CHRptr[0];
if ((addr >= 0) && (addr < (int)cdloggerVideoDataSize))
logcache1[i] = cdloggervdata[addr];
} else {
logcache0[i] = 0;
logcache1[i] = 0;
}
}
if(refreshchr)
{
for (i = 0, x=0x1000; i < 0x1000; i++, x++)
{
chrcache0[i] = VPage[i>>10][i];
chrcache1[i] = VPage[x>>10][x];
if (cdloggerVideoDataSize)
{
int addr;
addr = &VPage[i >> 10][i] - CHRptr[0];
if ((addr >= 0) && (addr < (int)cdloggerVideoDataSize))
logcache0[i] = cdloggervdata[addr];
addr = &VPage[x >> 10][x] - CHRptr[0];
if ((addr >= 0) && (addr < (int)cdloggerVideoDataSize))
logcache1[i] = cdloggervdata[addr];
} else
{
logcache0[i] = 0;
logcache1[i] = 0;
}
}
}
//update palette only if required
if(memcmp(palcache,PALRAM,32) != 0) { //bbit note: let para know that this if is useless and
//cache palette content will not work because of the lines below that change
memcpy(palcache,PALRAM,32); //palcache which will make it not equal next time
palcache[0x10] = palcache[0x00];
palcache[0x14] = palcache[0x00];
palcache[0x18] = palcache[0x00];
palcache[0x1C] = palcache[0x00];
// update palette only if required
if (memcmp(palcache, PALRAM, 32) != 0)
{
// bbit note: let para know that this if is useless and
// will not work because of the lines below that change
// palcache which will make it not equal next time
//draw palettes
for (y = 0; y < PALETTEHEIGHT; y++) {
for (x = 0; x < PALETTEWIDTH; x++) {
i = (((y>>5)<<4)+(x>>5));
*(uint8*)(pbitmap++) = palo[palcache[i]].b;
*(uint8*)(pbitmap++) = palo[palcache[i]].g;
*(uint8*)(pbitmap++) = palo[palcache[i]].r;
}
}
// cache palette content
memcpy(palcache,PALRAM,32);
palcache[0x10] = palcache[0x00];
palcache[0x14] = palcache[0x00];
palcache[0x18] = palcache[0x00];
palcache[0x1C] = palcache[0x00];
//draw line seperators on palette
pbitmap = (ppuv_palette+PALETTEBITWIDTH*31);
for (x = 0; x < PALETTEWIDTH*2; x++) {
*(uint8*)(pbitmap++) = 0;
*(uint8*)(pbitmap++) = 0;
*(uint8*)(pbitmap++) = 0;
}
pbitmap = (ppuv_palette-3);
for (y = 0; y < 64*3; y++) {
if(!(y%3)) pbitmap += (32*4*3);
for (x = 0; x < 6; x++) {
*(uint8*)(pbitmap++) = 0;
}
pbitmap += ((32*4*3)-6);
}
memcpy(palcache,PALRAM,32); //palcache which will make it not equal next time
}
//draw palettes
for (y = 0; y < PALETTEHEIGHT; y++)
{
for (x = 0; x < PALETTEWIDTH; x++)
{
i = (((y>>5)<<4)+(x>>5));
*(uint8*)(pbitmap++) = palo[palcache[i]].b;
*(uint8*)(pbitmap++) = palo[palcache[i]].g;
*(uint8*)(pbitmap++) = palo[palcache[i]].r;
}
}
DrawPatternTable(pattern0,chrcache0,logcache0,pindex0);
DrawPatternTable(pattern1,chrcache1,logcache1,pindex1);
//draw line seperators on palette
pbitmap = (ppuv_palette+PALETTEBITWIDTH*31);
for (x = 0; x < PALETTEWIDTH*2; x++)
{
*(uint8*)(pbitmap++) = 0;
*(uint8*)(pbitmap++) = 0;
*(uint8*)(pbitmap++) = 0;
}
pbitmap = (ppuv_palette-3);
for (y = 0; y < 64*3; y++)
{
if (!(y%3)) pbitmap += (32*4*3);
for (x = 0; x < 6; x++)
{
*(uint8*)(pbitmap++) = 0;
}
pbitmap += ((32*4*3)-6);
}
memcpy(palcache,PALRAM,32); //palcache which will make it not equal next time
}
//PPUViewDoBlit();
DrawPatternTable(pattern0,chrcache0,logcache0,pindex0);
DrawPatternTable(pattern1,chrcache1,logcache1,pindex1);
//PPUViewDoBlit();
}
void KillPPUView() {
void KillPPUView()
{
//GDI cleanup
DeleteObject(TmpBmp0);
SelectObject(TmpDC0,TmpObj0);
@ -230,155 +260,232 @@ void KillPPUView() {
PPUViewSkip=0;
}
BOOL CALLBACK PPUViewCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
RECT wrect;
char str[20];
BOOL CALLBACK PPUViewCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
RECT wrect;
char str[20];
switch(uMsg) {
case WM_INITDIALOG:
if (PPUViewPosX==-32000) PPUViewPosX=0; //Just in case
if (PPUViewPosY==-32000) PPUViewPosY=0;
SetWindowPos(hwndDlg,0,PPUViewPosX,PPUViewPosY,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER);
switch(uMsg)
{
case WM_INITDIALOG:
{
if (PPUViewPosX==-32000) PPUViewPosX=0; //Just in case
if (PPUViewPosY==-32000) PPUViewPosY=0;
SetWindowPos(hwndDlg,0,PPUViewPosX,PPUViewPosY,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER);
//prepare the bitmap attributes
//pattern tables
memset(&bmInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biWidth = PATTERNWIDTH;
bmInfo.bmiHeader.biHeight = PATTERNHEIGHT;
bmInfo.bmiHeader.biPlanes = 1;
bmInfo.bmiHeader.biBitCount = 24;
// calculate bitmaps positions relative to their groupboxes
RECT rect;
POINT pt;
GetWindowRect(GetDlgItem(hwndDlg, GRP_PPUVIEW_TABLES), &rect);
pt.x = rect.left;
pt.y = rect.top;
ScreenToClient(hwndDlg, &pt);
patternDestX = pt.x + PATTERNDESTX_BASE;
patternDestY = pt.y + PATTERNDESTY_BASE;
GetWindowRect(GetDlgItem(hwndDlg, LBL_PPUVIEW_PALETTES), &rect);
pt.x = rect.left;
pt.y = rect.top;
ScreenToClient(hwndDlg, &pt);
paletteDestX = pt.x + PALETTEDESTX_BASE;
paletteDestY = pt.y + PALETTEDESTY_BASE;
//prepare the bitmap attributes
//pattern tables
memset(&bmInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biWidth = PATTERNWIDTH;
bmInfo.bmiHeader.biHeight = PATTERNHEIGHT;
bmInfo.bmiHeader.biPlanes = 1;
bmInfo.bmiHeader.biBitCount = 24;
//palettes
memset(&bmInfo2.bmiHeader,0,sizeof(BITMAPINFOHEADER));
bmInfo2.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo2.bmiHeader.biWidth = PALETTEWIDTH;
bmInfo2.bmiHeader.biHeight = PALETTEHEIGHT;
bmInfo2.bmiHeader.biPlanes = 1;
bmInfo2.bmiHeader.biBitCount = 24;
//palettes
memset(&bmInfo2.bmiHeader,0,sizeof(BITMAPINFOHEADER));
bmInfo2.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo2.bmiHeader.biWidth = PALETTEWIDTH;
bmInfo2.bmiHeader.biHeight = PALETTEHEIGHT;
bmInfo2.bmiHeader.biPlanes = 1;
bmInfo2.bmiHeader.biBitCount = 24;
//create memory dcs
pDC = GetDC(hwndDlg); // GetDC(GetDlgItem(hwndDlg,GRP_PPUVIEW_TABLES));
TmpDC0 = CreateCompatibleDC(pDC); //pattern table 0
TmpDC1 = CreateCompatibleDC(pDC); //pattern table 1
TmpDC2 = CreateCompatibleDC(pDC); //palettes
//create memory dcs
pDC = GetDC(hwndDlg); // GetDC(GetDlgItem(hwndDlg,GRP_PPUVIEW_TABLES));
TmpDC0 = CreateCompatibleDC(pDC); //pattern table 0
TmpDC1 = CreateCompatibleDC(pDC); //pattern table 1
TmpDC2 = CreateCompatibleDC(pDC); //palettes
//create bitmaps and select them into the memory dc's
TmpBmp0 = CreateDIBSection(pDC,&bmInfo,DIB_RGB_COLORS,(void**)&pattern0,0,0);
TmpObj0 = SelectObject(TmpDC0,TmpBmp0);
TmpBmp1 = CreateDIBSection(pDC,&bmInfo,DIB_RGB_COLORS,(void**)&pattern1,0,0);
TmpObj1 = SelectObject(TmpDC1,TmpBmp1);
TmpBmp2 = CreateDIBSection(pDC,&bmInfo2,DIB_RGB_COLORS,(void**)&ppuv_palette,0,0);
TmpObj2 = SelectObject(TmpDC2,TmpBmp2);
//create bitmaps and select them into the memory dc's
TmpBmp0 = CreateDIBSection(pDC,&bmInfo,DIB_RGB_COLORS,(void**)&pattern0,0,0);
TmpObj0 = SelectObject(TmpDC0,TmpBmp0);
TmpBmp1 = CreateDIBSection(pDC,&bmInfo,DIB_RGB_COLORS,(void**)&pattern1,0,0);
TmpObj1 = SelectObject(TmpDC1,TmpBmp1);
TmpBmp2 = CreateDIBSection(pDC,&bmInfo2,DIB_RGB_COLORS,(void**)&ppuv_palette,0,0);
TmpObj2 = SelectObject(TmpDC2,TmpBmp2);
//Refresh Trackbar
SendDlgItemMessage(hwndDlg,CTL_PPUVIEW_TRACKBAR,TBM_SETRANGE,0,(LPARAM)MAKELONG(0,25));
SendDlgItemMessage(hwndDlg,CTL_PPUVIEW_TRACKBAR,TBM_SETPOS,1,PPUViewRefresh);
//Refresh Trackbar
SendDlgItemMessage(hwndDlg,CTL_PPUVIEW_TRACKBAR,TBM_SETRANGE,0,(LPARAM)MAKELONG(0,25));
SendDlgItemMessage(hwndDlg,CTL_PPUVIEW_TRACKBAR,TBM_SETPOS,1,PPUViewRefresh);
//Set Text Limit
SendDlgItemMessage(hwndDlg,IDC_PPUVIEW_SCANLINE,EM_SETLIMITTEXT,3,0);
CheckDlgButton(hwndDlg, IDC_MASK_UNUSED_GRAPHICS, PPUView_maskUnusedGraphics ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_INVERT_THE_MASK, PPUView_invertTheMask ? BST_CHECKED : BST_UNCHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_INVERT_THE_MASK), PPUView_maskUnusedGraphics ? true : false);
//force redraw the first time the PPU Viewer is opened
PPUViewSkip=100;
//Set Text Limit
SendDlgItemMessage(hwndDlg,IDC_PPUVIEW_SCANLINE,EM_SETLIMITTEXT,3,0);
//clear cache
memset(palcache,0,32);
memset(chrcache0,0,0x1000);
memset(chrcache1,0,0x1000);
memset(logcache0,0,0x1000);
memset(logcache1,0,0x1000);
//force redraw the first time the PPU Viewer is opened
PPUViewSkip=100;
PPUViewer=1;
break;
case WM_PAINT:
PPUViewDoBlit();
break;
case WM_CLOSE:
case WM_QUIT:
KillPPUView();
break;
case WM_MOVING:
break;
case WM_MOVE:
if (!IsIconic(hwndDlg)) {
GetWindowRect(hwndDlg,&wrect);
PPUViewPosX = wrect.left;
PPUViewPosY = wrect.top;
//clear cache
memset(palcache,0,32);
memset(chrcache0,0,0x1000);
memset(chrcache1,0,0x1000);
memset(logcache0,0,0x1000);
memset(logcache1,0,0x1000);
#ifdef WIN32
WindowBoundsCheckNoResize(PPUViewPosX,PPUViewPosY,wrect.right);
#endif
PPUViewer=1;
break;
}
case WM_PAINT:
PPUViewDoBlit();
break;
case WM_CLOSE:
case WM_QUIT:
KillPPUView();
break;
case WM_MOVING:
break;
case WM_MOVE:
if (!IsIconic(hwndDlg)) {
GetWindowRect(hwndDlg,&wrect);
PPUViewPosX = wrect.left;
PPUViewPosY = wrect.top;
#ifdef WIN32
WindowBoundsCheckNoResize(PPUViewPosX,PPUViewPosY,wrect.right);
#endif
}
break;
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
{
// redraw now
PPUViewSkip = PPUViewRefresh;
FCEUD_UpdatePPUView(-1, 0);
PPUViewDoBlit();
break;
}
case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN:
{
mouse_x = GET_X_LPARAM(lParam);
mouse_y = GET_Y_LPARAM(lParam);
if(((mouse_x >= patternDestX) && (mouse_x < (patternDestX + (PATTERNWIDTH * ZOOM)))) && (mouse_y >= patternDestY) && (mouse_y < (patternDestY + (PATTERNHEIGHT * ZOOM))))
{
if (pindex0 == 7)
pindex0 = 0;
else
pindex0++;
} else if(((mouse_x >= patternDestX + (PATTERNWIDTH * ZOOM) + 1) && (mouse_x < (patternDestX + (PATTERNWIDTH * ZOOM) * 2 + 1))) && (mouse_y >= patternDestY) && (mouse_y < (patternDestY + (PATTERNHEIGHT * ZOOM))))
{
if (pindex1 == 7)
pindex1 = 0;
else
pindex1++;
}
// redraw now
PPUViewSkip = PPUViewRefresh;
FCEUD_UpdatePPUView(-1, 0);
PPUViewDoBlit();
break;
}
case WM_MOUSEMOVE:
mouse_x = GET_X_LPARAM(lParam);
mouse_y = GET_Y_LPARAM(lParam);
if (((mouse_x >= patternDestX) && (mouse_x < (patternDestX + (PATTERNWIDTH * ZOOM)))) && (mouse_y >= patternDestY) && (mouse_y < (patternDestY + (PATTERNHEIGHT * ZOOM))))
{
mouse_x = (mouse_x - patternDestX) / (8 * ZOOM);
mouse_y = (mouse_y - patternDestY) / (8 * ZOOM);
sprintf(str,"Tile: $%X%X",mouse_y,mouse_x);
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,str);
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,"Tile:");
SetDlgItemText(hwndDlg,LBL_PPUVIEW_PALETTES,"Palettes");
} else if (((mouse_x >= patternDestX + (PATTERNWIDTH * ZOOM) + 1) && (mouse_x < (patternDestX + (PATTERNWIDTH * ZOOM) * 2 + 1))) && (mouse_y >= patternDestY) && (mouse_y < (patternDestY + (PATTERNHEIGHT * ZOOM))))
{
mouse_x = (mouse_x - (patternDestX + (PATTERNWIDTH * ZOOM) + 1)) / (8 * ZOOM);
mouse_y = (mouse_y - patternDestY) / (8 * ZOOM);
sprintf(str,"Tile: $%X%X",mouse_y,mouse_x);
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,str);
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,"Tile:");
SetDlgItemText(hwndDlg,LBL_PPUVIEW_PALETTES,"Palettes");
}
else if(((mouse_x >= paletteDestX) && (mouse_x < (paletteDestX + PALETTEWIDTH))) && (mouse_y >= paletteDestY) && (mouse_y < (paletteDestY + PALETTEHEIGHT)))
{
mouse_x = (mouse_x - paletteDestX) / 32;
mouse_y = (mouse_y - paletteDestY) / 32;
sprintf(str,"Palette: $%02X",palcache[(mouse_y<<4)|mouse_x]);
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,"Tile:");
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,"Tile:");
SetDlgItemText(hwndDlg,LBL_PPUVIEW_PALETTES,str);
} else
{
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,"Tile:");
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,"Tile:");
SetDlgItemText(hwndDlg,LBL_PPUVIEW_PALETTES,"Palettes");
}
break;
case WM_NCACTIVATE:
sprintf(str,"%d",PPUViewScanline);
SetDlgItemText(hwndDlg,IDC_PPUVIEW_SCANLINE,str);
break;
case WM_COMMAND:
{
switch(HIWORD(wParam))
{
case EN_UPDATE:
{
GetDlgItemText(hwndDlg,IDC_PPUVIEW_SCANLINE,str,4);
sscanf(str,"%d",&PPUViewScanline);
if(PPUViewScanline > 239) PPUViewScanline = 239;
break;
}
case BN_CLICKED:
{
switch(LOWORD(wParam))
{
case IDC_MASK_UNUSED_GRAPHICS:
{
PPUView_maskUnusedGraphics ^= 1;
CheckDlgButton(hwndDlg, IDC_MASK_UNUSED_GRAPHICS, PPUView_maskUnusedGraphics ? BST_CHECKED : BST_UNCHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_INVERT_THE_MASK), PPUView_maskUnusedGraphics ? true : false);
// redraw now
PPUViewSkip = PPUViewRefresh;
FCEUD_UpdatePPUView(-1, 0);
PPUViewDoBlit();
break;
}
break;
case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN:
mouse_x = GET_X_LPARAM(lParam);
mouse_y = GET_Y_LPARAM(lParam);
if(((mouse_x >= PATTERNDESTX) && (mouse_x < (PATTERNDESTX+(PATTERNWIDTH*ZOOM)))) && (mouse_y >= PATTERNDESTY) && (mouse_y < (PATTERNDESTY+(PATTERNHEIGHT*ZOOM)))) {
if(pindex0 == 7) pindex0 = 0;
else pindex0++;
}
else if(((mouse_x >= PATTERNDESTX+(PATTERNWIDTH*ZOOM)+1) && (mouse_x < (PATTERNDESTX+(PATTERNWIDTH*ZOOM)*2+1))) && (mouse_y >= PATTERNDESTY) && (mouse_y < (PATTERNDESTY+(PATTERNHEIGHT*ZOOM)))) {
if(pindex1 == 7) pindex1 = 0;
else pindex1++;
}
FCEUD_UpdatePPUView(-1, 0);
PPUViewDoBlit();
break;
case WM_MOUSEMOVE:
mouse_x = GET_X_LPARAM(lParam);
mouse_y = GET_Y_LPARAM(lParam);
if(((mouse_x >= PATTERNDESTX) && (mouse_x < (PATTERNDESTX+(PATTERNWIDTH*ZOOM)))) && (mouse_y >= PATTERNDESTY) && (mouse_y < (PATTERNDESTY+(PATTERNHEIGHT*ZOOM)))) {
mouse_x = (mouse_x-PATTERNDESTX)/(8*ZOOM);
mouse_y = (mouse_y-PATTERNDESTY)/(8*ZOOM);
sprintf(str,"Tile: $%X%X",mouse_y,mouse_x);
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,str);
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,"Tile:");
SetDlgItemText(hwndDlg,LBL_PPUVIEW_PALETTES,"Palettes");
}
else if(((mouse_x >= PATTERNDESTX+(PATTERNWIDTH*ZOOM)+1) && (mouse_x < (PATTERNDESTX+(PATTERNWIDTH*ZOOM)*2+1))) && (mouse_y >= PATTERNDESTY) && (mouse_y < (PATTERNDESTY+(PATTERNHEIGHT*ZOOM)))) {
mouse_x = (mouse_x-(PATTERNDESTX+(PATTERNWIDTH*ZOOM)+1))/(8*ZOOM);
mouse_y = (mouse_y-PATTERNDESTY)/(8*ZOOM);
sprintf(str,"Tile: $%X%X",mouse_y,mouse_x);
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,str);
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,"Tile:");
SetDlgItemText(hwndDlg,LBL_PPUVIEW_PALETTES,"Palettes");
}
else if(((mouse_x >= PALETTEDESTX) && (mouse_x < (PALETTEDESTX+PALETTEWIDTH))) && (mouse_y >= PALETTEDESTY) && (mouse_y < (PALETTEDESTY+PALETTEHEIGHT))) {
mouse_x = (mouse_x-PALETTEDESTX)/32;
mouse_y = (mouse_y-PALETTEDESTY)/32;
sprintf(str,"Palette: $%02X",palcache[(mouse_y<<4)|mouse_x]);
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,"Tile:");
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,"Tile:");
SetDlgItemText(hwndDlg,LBL_PPUVIEW_PALETTES,str);
}
else {
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE1,"Tile:");
SetDlgItemText(hwndDlg,LBL_PPUVIEW_TILE2,"Tile:");
SetDlgItemText(hwndDlg,LBL_PPUVIEW_PALETTES,"Palettes");
}
break;
case WM_NCACTIVATE:
sprintf(str,"%d",PPUViewScanline);
SetDlgItemText(hwndDlg,IDC_PPUVIEW_SCANLINE,str);
break;
case WM_COMMAND:
switch(HIWORD(wParam)) {
case EN_UPDATE:
GetDlgItemText(hwndDlg,IDC_PPUVIEW_SCANLINE,str,4);
sscanf(str,"%d",&PPUViewScanline);
if(PPUViewScanline > 239) PPUViewScanline = 239;
break;
}
break;
case WM_HSCROLL:
if(lParam) { //refresh trackbar
PPUViewRefresh = SendDlgItemMessage(hwndDlg,CTL_PPUVIEW_TRACKBAR,TBM_GETPOS,0,0);
case IDC_INVERT_THE_MASK:
{
PPUView_invertTheMask ^= 1;
CheckDlgButton(hwndDlg, IDC_INVERT_THE_MASK, PPUView_invertTheMask ? BST_CHECKED : BST_UNCHECKED);
// redraw now
PPUViewSkip = PPUViewRefresh;
FCEUD_UpdatePPUView(-1, 0);
PPUViewDoBlit();
break;
}
break;
}
return FALSE;
}
}
}
break;
}
case WM_HSCROLL:
if(lParam)
{
//refresh trackbar
PPUViewRefresh = SendDlgItemMessage(hwndDlg,CTL_PPUVIEW_TRACKBAR,TBM_GETPOS,0,0);
}
break;
}
return FALSE;
}
void DoPPUView()
@ -398,6 +505,8 @@ void DoPPUView()
//SetWindowPos(hPPUView,HWND_TOP,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER);
ShowWindow(hPPUView, SW_SHOWNORMAL);
SetForegroundWindow(hPPUView);
// redraw now
PPUViewSkip = PPUViewRefresh;
FCEUD_UpdatePPUView(-1,1);
PPUViewDoBlit();
}

View File

@ -1624,20 +1624,23 @@ BEGIN
GROUPBOX "Logging workflow options",65528,8,142,171,52
END
PPUVIEW DIALOGEX 44, 38, 355, 246
PPUVIEW DIALOGEX 44, 38, 355, 260
STYLE DS_SETFONT | DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "PPU Viewer"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
GROUPBOX "Pattern Tables",GRP_PPUVIEW_TABLES,2,-1,351,192,WS_TABSTOP
LTEXT "Tile:",LBL_PPUVIEW_TILE1,6,168,50,10
LTEXT "Tile:",LBL_PPUVIEW_TILE2,177,168,50,10
GROUPBOX "Pattern Tables",GRP_PPUVIEW_TABLES,2,-1,351,204,WS_TABSTOP
LTEXT "Tile:",LBL_PPUVIEW_TILE1,6,169,50,9
LTEXT "Tile:",LBL_PPUVIEW_TILE2,177,169,50,9
CONTROL "",CTL_PPUVIEW_TRACKBAR,"msctls_trackbar32",WS_TABSTOP,227,178,106,11
LTEXT "Refresh: More",-1,177,178,50,10
LTEXT "Refresh: More",-1,177,178,50,9
LTEXT "Less",-1,334,178,18,10
GROUPBOX "Palettes",LBL_PPUVIEW_PALETTES,2,192,351,53,WS_TABSTOP
LTEXT "Display on scanline:",-1,6,178,65,10
GROUPBOX "Palettes",LBL_PPUVIEW_PALETTES,2,204,351,53,WS_TABSTOP
LTEXT "Display on scanline:",-1,6,178,65,9
EDITTEXT IDC_PPUVIEW_SCANLINE,72,176,27,12
CONTROL "Mask unused graphics (needs Code/Data Logger)",IDC_MASK_UNUSED_GRAPHICS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,189,169,10
CONTROL "Invert the mask",IDC_INVERT_THE_MASK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,177,189,61,10
END
ARCHIVECHOOSERDIALOG DIALOGEX 0, 0, 265, 159
@ -2108,6 +2111,7 @@ BEGIN
"PPUVIEW", DIALOG
BEGIN
BOTTOMMARGIN, 258
END
"ARCHIVECHOOSERDIALOG", DIALOG

View File

@ -578,7 +578,6 @@
#define IDC_HISTORYLIST 1149
#define IDC_SYMBOLIC_NAME 1149
#define IDC_BOOKMARKSLIST 1150
#define IDC_SYMBOLIC_ADDRESS2 1150
#define IDC_SYMBOLIC_FILENAME 1150
#define TASEDITOR_NEXT_MARKER 1151
#define IDC_SYMBOLIC_COMMENT 1151
@ -629,6 +628,7 @@
#define IDC_MATCH_CASE 1203
#define IDC_COPY_INPUT 1203
#define IDC_AUTORESUMECDLOGGING 1203
#define IDC_MASK_UNUSED_GRAPHICS 1203
#define IDC_VOLUMEGROUP 1204
#define IDC_OMITBLANK 1204
#define IDC_CHECK3 1204
@ -637,6 +637,8 @@
#define IDC_COPY_MARKERS 1204
#define IDC_AUTORESUMECDLOGGING2 1204
#define IDC_AUTOSAVECDL 1204
#define IDC_USE_CDLOGGER_DATA2 1204
#define IDC_INVERT_THE_MASK 1204
#define IDC_RAMLIST 1205
#define IDC_CHECK4 1205
#define IDC_CHECK_BOOKMARKS 1205

View File

@ -813,7 +813,8 @@ void UpdateLogText(void)
return;
}
void EnableTracerMenuItems(void){
void EnableTracerMenuItems(void)
{
if(logging)
{
EnableWindow(GetDlgItem(hTracer,IDC_RADIO_LOG_LAST),FALSE);

View File

@ -1270,15 +1270,18 @@ static int memory_readbytesigned(lua_State *L) {
return 1;
}
static int GetWord(lua_State *L, bool isSigned) {
uint16 address1 = luaL_checkinteger(L,1);
uint16 address2 = luaL_checkinteger(L,1)+1;
if (lua_type(L,2) == LUA_TNUMBER) address2 = luaL_checkinteger(L,2);
uint32 result = FCEU_CheatGetByte(address1) + FCEU_CheatGetByte(address2)*256; // little endian
return isSigned ? (int16) result : result;
static int GetWord(lua_State *L, bool isSigned)
{
uint16 addressLow = luaL_checkinteger(L,1);
uint16 addressHigh = addressLow + 1; // little endian
if (lua_type(L,2) == LUA_TNUMBER)
addressHigh = luaL_checkinteger(L,2);
uint32 result = FCEU_CheatGetByte(addressLow) + (FCEU_CheatGetByte(addressHigh) << 8);
return isSigned ? (int16)result : result;
}
static int memory_readword(lua_State *L) {
static int memory_readword(lua_State *L)
{
lua_pushinteger(L, GetWord(L, false));
return 1;
}
@ -5371,9 +5374,10 @@ static const struct luaL_reg memorylib [] = {
{"readbyte", memory_readbyte},
{"readbyterange", memory_readbyterange},
{"readbytesigned", memory_readbytesigned},
{"readbyteunsigned", memory_readbyte}, // alternate naming scheme for unsigned
{"readbyteunsigned", memory_readbyte}, // alternate naming scheme for unsigned
{"readword", memory_readword},
{"readwordsigned", memory_readwordsigned},
{"readwordunsigned", memory_readword}, // alternate naming scheme for unsigned
{"writebyte", memory_writebyte},
{"getregister", memory_getregister},
{"setregister", memory_setregister},

Binary file not shown.