📄 nestreme.cpp
字号:
case VK_ESCAPE:
bRunning = FALSE;
break;
case 0x41: // A
Joy1.SetButton(JOYSELECT);
break;
case 0x53: // S
Joy1.SetButton(JOYSTART);
break;
case 0x5A: // Z
Joy1.SetButton(JOYB);
break;
case 0x58: // X
Joy1.SetButton(JOYA);
break;
case VK_UP:
Joy1.SetButton(JOYUP);
break;
case VK_DOWN:
Joy1.SetButton(JOYDOWN);
break;
case VK_LEFT:
Joy1.SetButton(JOYLEFT);
break;
case VK_RIGHT:
Joy1.SetButton(JOYRIGHT);
break;
case 0x31: // 1
Options_bBackgroundEnabled ^= TRUE;
break;
case 0x32: // 2
Options_bSpritesEnabled ^= TRUE;
break;
default:
break;
}
break;
case WM_KEYUP:
switch (wParam)
{
case 0x41: // A
Joy1.ClearButton(JOYSELECT);
break;
case 0x53: // S
Joy1.ClearButton(JOYSTART);
break;
case 0x5A: // Z
Joy1.ClearButton(JOYB);
break;
case 0x58: // X
Joy1.ClearButton(JOYA);
break;
case VK_UP:
Joy1.ClearButton(JOYUP);
break;
case VK_DOWN:
Joy1.ClearButton(JOYDOWN);
break;
case VK_LEFT:
Joy1.ClearButton(JOYLEFT);
break;
case VK_RIGHT:
Joy1.ClearButton(JOYRIGHT);
break;
default:
break;
}
break;
case WM_SIZE:
UpdateBounds(hwnd);
default:
return DefMDIChildProc(hwnd, uMsg, wParam, lParam);
}
return 0;
} // end WndProcRun()
//------------------------------------------------------------------------------
// Name: AddBreakpoint()
// Desc: Adds a breakpoint to the array of breakpoints.
//------------------------------------------------------------------------------
HRESULT AddBreakpoint(WORD wAddress, UINT uListViewItem)
{
// As long as we have room for another breakpoint add it to the array,
// and check the list view check box.
if (dwNumBreakpoints < OPTIONS_NUM_BREAKPOINTS)
{
awBreakpoints[dwNumBreakpoints++] = wAddress;
ListView_Check(hwndCodeLV, uListViewItem);
}
else
FATAL(hwndMain, "No more breakpoints allowed.");
return S_OK;
} // end AddBreakpoint()
//------------------------------------------------------------------------------
// Name: AddRegistersToListView()
// Desc: Adds all the registers to the registers list view.
//------------------------------------------------------------------------------
HRESULT AddRegistersToListView()
{
char strText[128]; // Text to hold the info to be added.
// Add the A register.
ADD_VAR_TO_REG_LISTVIEW(0, "A", CPU.A);
// Add the X register.
ADD_VAR_TO_REG_LISTVIEW(1, "X", CPU.X);
// Add the Y register.
ADD_VAR_TO_REG_LISTVIEW(2, "Y", CPU.Y);
// Add the SP register.
ADD_VAR_TO_REG_LISTVIEW(3, "SP", CPU.S);
// Add the PC register.
ADD_VAR_TO_REG_LISTVIEW(4, "PC", CPU.P);
// Add the flags register.
ADD_VAR_TO_REG_LISTVIEW(5, "Flags", CPU.F);
// Add a blank space in the list view.
ADD_BLANK_TO_REG_LISTVIEW(6);
// Add the Nintendo registers to the list view.
ADD_VAR_TO_REG_LISTVIEW(7, "$2000", CPU.Memory[0x2000]);
ADD_VAR_TO_REG_LISTVIEW(8, "$2001", CPU.Memory[0x2001]);
ADD_VAR_TO_REG_LISTVIEW(9, "$2002", CPU.Memory[0x2002]);
ADD_VAR_TO_REG_LISTVIEW(10, "$2003", CPU.Memory[0x2003]);
ADD_VAR_TO_REG_LISTVIEW(11, "$2004", CPU.Memory[0x2004]);
ADD_VAR_TO_REG_LISTVIEW(12, "$2005", CPU.Memory[0x2005]);
ADD_VAR_TO_REG_LISTVIEW(13, "$2006", CPU.Memory[0x2006]);
ADD_VAR_TO_REG_LISTVIEW(14, "$2007", CPU.Memory[0x2007]);
ADD_VAR_TO_REG_LISTVIEW(15, "$4000", CPU.Memory[0x4000]);
ADD_VAR_TO_REG_LISTVIEW(16, "$4001", CPU.Memory[0x4001]);
ADD_VAR_TO_REG_LISTVIEW(17, "$4002", CPU.Memory[0x4002]);
ADD_VAR_TO_REG_LISTVIEW(18, "$4003", CPU.Memory[0x4003]);
ADD_VAR_TO_REG_LISTVIEW(19, "$4004", CPU.Memory[0x4004]);
ADD_VAR_TO_REG_LISTVIEW(20, "$4005", CPU.Memory[0x4005]);
ADD_VAR_TO_REG_LISTVIEW(21, "$4006", CPU.Memory[0x4006]);
ADD_VAR_TO_REG_LISTVIEW(22, "$4007", CPU.Memory[0x4007]);
ADD_VAR_TO_REG_LISTVIEW(23, "$4008", CPU.Memory[0x4008]);
ADD_VAR_TO_REG_LISTVIEW(24, "$4009", CPU.Memory[0x4009]);
ADD_VAR_TO_REG_LISTVIEW(25, "$4010", CPU.Memory[0x4010]);
ADD_VAR_TO_REG_LISTVIEW(26, "$4011", CPU.Memory[0x4011]);
ADD_VAR_TO_REG_LISTVIEW(17, "$4012", CPU.Memory[0x4012]);
ADD_VAR_TO_REG_LISTVIEW(18, "$4013", CPU.Memory[0x4013]);
ADD_VAR_TO_REG_LISTVIEW(19, "$4014", CPU.Memory[0x4014]);
ADD_VAR_TO_REG_LISTVIEW(30, "$4015", CPU.Memory[0x4015]);
ADD_VAR_TO_REG_LISTVIEW(31, "$4016", CPU.Memory[0x4016]);
ADD_VAR_TO_REG_LISTVIEW(32, "$4017", CPU.Memory[0x4017]);
// Add a blank space in the list view.
ADD_BLANK_TO_REG_LISTVIEW(33);
// Add the cycles to the list view.
sprintf(strText, "Cycles");
InsertListViewText(hwndRegsLV, 34, 0, strText);
sprintf(strText, "%d", CPU.byCycles);
InsertListViewText(hwndRegsLV, 34, 1, strText);
// Add the scanlines to the list view.
sprintf(strText, "Scanline");
InsertListViewText(hwndRegsLV, 35, 0, strText);
sprintf(strText, "%d", wScanline);
InsertListViewText(hwndRegsLV, 35, 1, strText);
// Add the VRAM address to the list view.
ADD_VAR_TO_REG_LISTVIEW(36, "VRAM Address", wVRAMAddress);
return S_OK;
} // end AddRegistersToListView()
//------------------------------------------------------------------------------
// Name: CleanUp()
// Desc: Deletes everthing that has been dynamically created.
//------------------------------------------------------------------------------
HRESULT CleanUp()
{
// Delete our rom that we allocated.
FreeNESFile();
return S_OK;
} // end CleanUp()
//------------------------------------------------------------------------------
// Name: CreateMemoryDump()
// Desc: Creates an edit control to hold our memory contents and
// a button for refreshing them.
//------------------------------------------------------------------------------
HRESULT CreateMemoryDump(HWND hwndParent, HWND* phwndEdit, HWND* phwndButton)
{
// Create the edit control.
*phwndEdit = CreateWindow("EDIT", NULL,
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | ES_LEFT | ES_MULTILINE | ES_READONLY,
20, 20, 200, 200, hwndParent, NULL, g_hInstance, NULL);
*phwndButton = CreateWindow(
"BUTTON", // predefined class
"Refresh", // button text
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // styles
0, // starting x position
0, // starting y position
40, // button width
20, // button height
hwndParent, // parent window
NULL, // No menu
g_hInstance,
NULL); // pointer not needed
// Set the text to a fixed width font and the background color to white.
SendMessage(*phwndEdit, WM_SETFONT, (WPARAM)GetStockObject(ANSI_FIXED_FONT), TRUE);
SendMessage(*phwndButton, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
return S_OK;
} // CreateMemoryDump()
//------------------------------------------------------------------------------
// Name: CreateDebugWindow()
// Desc: Creates the window to hold our disassembly and register contents.
// This is a MDI child window with a splitter to separate the registers
// and the code disassembly.
//------------------------------------------------------------------------------
HRESULT CreateDebugWindow(HWND hwndParent)
{
// Create the child window for the code and registers.
hwndDebugWnd = CreateWindowEx(WS_EX_MDICHILD,
strDebugClassName,
strDebugTitleName,
WS_CHILD,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
hwndMDIClient,
NULL,
g_hInstance,
NULL);
if (hwndDebugWnd == NULL)
FATAL(hwndParent, "Couldn't Create the debug window");
ShowWindow(hwndDebugWnd, SW_SHOWMAXIMIZED);
// Create the code list view box
hwndCodeLV = CreateListView(hwndDebugWnd, IDS_CODE_COLUMN0, 4);
if (hwndCodeLV == NULL)
FATAL(hwndParent, "Couldn't create the code list view. Make sure IE3 is installed.");
// Create the registers list view.
hwndRegsLV = CreateListView(hwndDebugWnd, IDS_REGS_COLUMN0, 2);
if (hwndCodeLV == NULL)
FATAL(hwndParent, "Couldn't create the registers list view. Make sure IE3 is installed.");
// Set the font to a fixed width font
SendMessage(hwndCodeLV, WM_SETFONT, (WPARAM)GetStockObject(ANSI_FIXED_FONT), TRUE);
SendMessage(hwndRegsLV, WM_SETFONT, (WPARAM)GetStockObject(ANSI_FIXED_FONT), TRUE);
// Set the extended styles for the list views.
ListView_SetExtendedListViewStyle(hwndCodeLV,
LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_CHECKBOXES);
// Create and resize the code and registers list boxes
// to fit the child window.
ResizeDebugControls(hwndDebugWnd, hwndCodeLV, hwndRegsLV);
// Add the registers to the registers list view.
AddRegistersToListView();
// Create the tooltip window for viewing our memory contents.
//CreateTooltip(hwndCodeLV, "Hello!");
//SendMessage(hwndCodeLV, LVM_SETTOOLTIPS, 0, (LPARAM)hwndTT);
return S_OK;
} // end CreateDebugWindow()
//------------------------------------------------------------------------------
// Name: CreateListView()
// Desc: Creates a list view control, initializes the columns, and
// returns the handle to the window if successful.
//------------------------------------------------------------------------------
HWND CreateListView(HWND hWndParent, UINT uFirstColRsc, UINT uNumColumns)
{
HWND hwndListView;
LV_COLUMN lvC;
char strCol[50];
// Create a list view control in report view.
hwndListView = CreateWindowEx(0L, WC_LISTVIEW, "", WS_VISIBLE | WS_CHILD |
WS_CHILD | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS,
0, 0, 0, 0, hWndParent,
NULL, g_hInstance, NULL);
if (hwndListView == NULL)
return NULL;
// Create columns.
lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvC.fmt = LVCFMT_LEFT;
lvC.cx = 150;
lvC.pszText = strCol;
// Add the columns.
for (UINT i = 0; i < uNumColumns; i++)
{
lvC.iSubItem = i;
LoadString(g_hInstance, uFirstColRsc+i, strCol, sizeof(strCol));
if (ListView_InsertColumn(hwndListView, i, &lvC) == -1)
return NULL;
}
return hwndListView;
} // end CreateListView()
//------------------------------------------------------------------------------
// Name: CreateMDIClientWindow()
// Desc: Creates the client window for our frame window.
//------------------------------------------------------------------------------
HRESULT CreateMDIClientWindow(HWND hwndFrame)
{
CLIENTCREATESTRUCT ccs;
// Retrieve the handle to the window menu and assign the
// first child window identifier.
ccs.hWindowMenu = GetSubMenu(GetMenu(hwndFrame), WINDOWMENU);
ccs.idFirstChild = IDM_WINDOWCHILD;
// Create the MDI client window.
hwndMDIClient = CreateWindow( "MDICLIENT", (LPCTSTR)NULL,
WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
0, 0, 0, 0, hwndFrame, (HMENU)0xCAC, g_hInstance, (LPSTR)&ccs);
ShowWindow(hwndMDIClient, SW_SHOW);
return S_OK;
} // end CreateMDIClientWindow()
//------------------------------------------------------------------------------
// Name: CreateMemoryWindow()
// Desc: Creates the window hold our memory contents.
//------------------------------------------------------------------------------
HRESULT CreateMemoryWindow(HWND hwndParent)
{
// Create the child window for the code and registers.
hwndMemoryWnd = CreateWindowEx(WS_EX_MDICHILD,
strMemoryClassName,
strMemoryTitleName,
WS_CHILD,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
hwndMDIClient,
NULL,
g_hInstance,
NULL);
if (hwndMemoryWnd == NULL)
FATAL(hwndParent, "Couldn't Create the debug window");
return S_OK;
} // end CreateMemoryWindow()
//------------------------------------------------------------------------------
// Name: CreateTabControl()
// Desc: Creates a tab control, sized to fit the specified parent window's
// client area, and adds the number of tabs passed into the function.
// All the strings in the string table must be in order.
//------------------------------------------------------------------------------
HWND WINAPI CreateTabControl(HWND hwndParent, UINT uTextResource, UINT uNumTabs)
{
RECT rcClient; // Client rectangle coordinates.
HWND hwndTab; // Window handle to the tab control.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -