From b5bce89e2e80680032409d62881b2e518e9e15a6 Mon Sep 17 00:00:00 2001 From: jeblanchard Date: Fri, 6 Jun 2008 00:15:47 +0000 Subject: [PATCH] Final resource cleanup: NAMEBOOKMARKDLG, ASSEMBLER, contextual menus in memview, and the (un-broken) special scaler in windowed mode. --- src/drivers/win/debugger.cpp | 38 ++++++++--------- src/drivers/win/memview.cpp | 79 ++++++++++++++++++++--------------- src/drivers/win/memviewsp.cpp | 16 +++---- src/drivers/win/memviewsp.h | 2 + src/drivers/win/res.rc | 38 +++++++++-------- src/drivers/win/resource.h | 11 ++++- src/drivers/win/video.cpp | 7 ++-- 7 files changed, 108 insertions(+), 83 deletions(-) diff --git a/src/drivers/win/debugger.cpp b/src/drivers/win/debugger.cpp index 0744dac8..9b9148d8 100644 --- a/src/drivers/win/debugger.cpp +++ b/src/drivers/win/debugger.cpp @@ -642,14 +642,14 @@ BOOL CALLBACK AssemblerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar CenterWindow(hwndDlg); //set font - SendDlgItemMessage(hwndDlg,101,WM_SETFONT,(WPARAM)hNewFont,FALSE); - SendDlgItemMessage(hwndDlg,102,WM_SETFONT,(WPARAM)hNewFont,FALSE); + SendDlgItemMessage(hwndDlg,IDC_ASSEMBLER_DISASSEMBLY,WM_SETFONT,(WPARAM)hNewFont,FALSE); + SendDlgItemMessage(hwndDlg,IDC_ASSEMBLER_PATCH_DISASM,WM_SETFONT,(WPARAM)hNewFont,FALSE); //set limits - SendDlgItemMessage(hwndDlg,100,CB_LIMITTEXT,20,0); + SendDlgItemMessage(hwndDlg,IDC_ASSEMBLER_HISTORY,CB_LIMITTEXT,20,0); - SetDlgItemText(hwndDlg,101,DisassembleLine(iaPC)); - SetFocus(GetDlgItem(hwndDlg,100)); + SetDlgItemText(hwndDlg,IDC_ASSEMBLER_DISASSEMBLY,DisassembleLine(iaPC)); + SetFocus(GetDlgItem(hwndDlg,IDC_ASSEMBLER_HISTORY)); patchlen = 0; applied = 0; @@ -664,7 +664,7 @@ BOOL CALLBACK AssemblerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar switch (HIWORD(wParam)) { case BN_CLICKED: switch (LOWORD(wParam)) { - case 201: //Apply + case IDC_ASSEMBLER_APPLY: if (patchlen) { ptr = GetNesPRGPointer(GetNesFileAddress(iaPC)-16); count = 0; @@ -679,7 +679,7 @@ BOOL CALLBACK AssemblerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar applied = 1; } break; - case 202: //Save... + case IDC_ASSEMBLER_SAVE: if (applied) { count = romaddr = GetNesFileAddress(iaPC); for (i = 0; i < patchlen; i++) count += opsize[patchdata[i][0]]; @@ -694,9 +694,9 @@ BOOL CALLBACK AssemblerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar } } break; - case 203: //Undo - if ((count = SendDlgItemMessage(hwndDlg,102,LB_GETCOUNT,0,0))) { - SendDlgItemMessage(hwndDlg,102,LB_DELETESTRING,count-1,0); + case IDC_ASSEMBLER_UNDO: + if ((count = SendDlgItemMessage(hwndDlg,IDC_ASSEMBLER_PATCH_DISASM,LB_GETCOUNT,0,0))) { + SendDlgItemMessage(hwndDlg,IDC_ASSEMBLER_PATCH_DISASM,LB_DELETESTRING,count-1,0); patchlen--; count = 0; for (i = 0; i < patchlen; i++) count += opsize[patchdata[i][0]]; @@ -709,13 +709,13 @@ BOOL CALLBACK AssemblerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar lastundo -= j; applied = 1; } - SetDlgItemText(hwndDlg,101,DisassembleLine(iaPC+count)); + SetDlgItemText(hwndDlg,IDC_ASSEMBLER_DISASSEMBLY,DisassembleLine(iaPC+count)); } break; - case 300: //Hidden default button + case IDC_ASSEMBLER_DEFPUSHBUTTON: count = 0; for (i = 0; i < patchlen; i++) count += opsize[patchdata[i][0]]; - GetDlgItemText(hwndDlg,100,str,21); + GetDlgItemText(hwndDlg,IDC_ASSEMBLER_HISTORY,str,21); if (!Assemble(patchdata[patchlen],(iaPC+count),str)) { count = iaPC; for (i = 0; i <= patchlen; i++) count += opsize[patchdata[i][0]]; @@ -723,12 +723,12 @@ BOOL CALLBACK AssemblerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar MessageBox(hwndDlg, "Patch data cannot exceed address 0xFFFF", "Address error", MB_OK); break; } - SetDlgItemText(hwndDlg,100,""); - if (count < 0x10000) SetDlgItemText(hwndDlg,101,DisassembleLine(count)); - else SetDlgItemText(hwndDlg,101,"OVERFLOW"); + SetDlgItemText(hwndDlg,IDC_ASSEMBLER_HISTORY,""); + if (count < 0x10000) SetDlgItemText(hwndDlg,IDC_ASSEMBLER_DISASSEMBLY,DisassembleLine(count)); + else SetDlgItemText(hwndDlg,IDC_ASSEMBLER_DISASSEMBLY,"OVERFLOW"); dasm = DisassembleData((count-opsize[patchdata[patchlen][0]]),patchdata[patchlen]); - SendDlgItemMessage(hwndDlg,102,LB_INSERTSTRING,-1,(LPARAM)(LPSTR)dasm); - AddAsmHistory(hwndDlg,100,dasm+16); + SendDlgItemMessage(hwndDlg,IDC_ASSEMBLER_PATCH_DISASM,LB_INSERTSTRING,-1,(LPARAM)(LPSTR)dasm); + AddAsmHistory(hwndDlg,IDC_ASSEMBLER_HISTORY,dasm+16); SetWindowText(hwndDlg, "Inline Assembler"); patchlen++; } @@ -738,7 +738,7 @@ BOOL CALLBACK AssemblerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar } break; } - SetFocus(GetDlgItem(hwndDlg,100)); //set focus to combo box after anything is pressed! + SetFocus(GetDlgItem(hwndDlg,IDC_ASSEMBLER_HISTORY)); //set focus to combo box after anything is pressed! break; } break; diff --git a/src/drivers/win/memview.cpp b/src/drivers/win/memview.cpp index af6c79a7..88597a7e 100644 --- a/src/drivers/win/memview.cpp +++ b/src/drivers/win/memview.cpp @@ -39,6 +39,19 @@ #define MODE_NES_PPU 1 #define MODE_NES_FILE 2 +#define ID_ADDRESS_FRZ_SUBMENU 1 +#define ID_ADDRESS_ADDBP_R 2 +#define ID_ADDRESS_ADDBP_W 3 +#define ID_ADDRESS_ADDBP_X 4 +#define ID_ADDRESS_SEEK_IN_ROM 5 +#define ID_ADDRESS_CREATE_GG_CODE 6 +#define ID_ADDRESS_BOOKMARK 20 + +#define ID_ADDRESS_FRZ_TOGGLE_STATE 1 +#define ID_ADDRESS_FRZ_FREEZE 50 +#define ID_ADDRESS_FRZ_UNFREEZE 51 +#define ID_ADDRESS_FRZ_SEP 52 +#define ID_ADDRESS_FRZ_UNFREEZE_ALL 53 // This defines all of our right click popup menus struct @@ -51,18 +64,18 @@ struct } popupmenu[] = { - {0,0x2000,0,1,"Freeze/Unfreeze This Address"}, - {0x6000,0x7FFF,0,1,"Freeze/Unfreeze This Address"}, - {0,0xFFFF,0,2,"Add Debugger Read Breakpoint"}, - {0,0x3FFF,1,2,"Add Debugger Read Breakpoint"}, - {0,0xFFFF,0,3,"Add Debugger Write Breakpoint"}, - {0,0x3FFF,1,3,"Add Debugger Write Breakpoint"}, - {0,0xFFFF,0,4,"Add Debugger Execute Breakpoint"}, - {0x8000,0xFFFF,0,5,"Go Here In Rom File"}, - {0x8000,0xFFFF,0,6,"Create Game Genie Code At This Address"}, - //{0,0xFFFFFF,2,7,"Create Game Genie Code At This Address"} + {0x0000,0x2000,0,ID_ADDRESS_FRZ_SUBMENU,"Freeze/Unfreeze This Address"}, + {0x6000,0x7FFF,0,ID_ADDRESS_FRZ_SUBMENU,"Freeze/Unfreeze This Address"}, + {0x0000,0xFFFF,0,ID_ADDRESS_ADDBP_R,"Add Debugger Read Breakpoint"}, + {0x0000,0x3FFF,1,ID_ADDRESS_ADDBP_R,"Add Debugger Read Breakpoint"}, + {0x0000,0xFFFF,0,ID_ADDRESS_ADDBP_W,"Add Debugger Write Breakpoint"}, + {0x0000,0x3FFF,1,ID_ADDRESS_ADDBP_W,"Add Debugger Write Breakpoint"}, + {0x0000,0xFFFF,0,ID_ADDRESS_ADDBP_X,"Add Debugger Execute Breakpoint"}, + {0x8000,0xFFFF,0,ID_ADDRESS_SEEK_IN_ROM,"Go Here In Rom File"}, + {0x8000,0xFFFF,0,ID_ADDRESS_CREATE_GG_CODE,"Create Game Genie Code At This Address"}, + //{0x0000,0xFFFFFF,2,7,"Create Game Genie Code At This Address"} // ################################## Start of SP CODE ########################### - {0, 0xFFFF, 0, 20, "Add / Remove bookmark"}, + {0x0000, 0xFFFF, 0, ID_ADDRESS_BOOKMARK, "Add / Remove bookmark"}, // ################################## End of SP CODE ########################### } ; @@ -1073,20 +1086,20 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa memset(&MenuInfo,0,sizeof(MENUITEMINFO)); switch(popupmenu[i].id){ //this will set the text for the menu dynamically based on the id // ################################## Start of SP CODE ########################### - case 1: + case ID_ADDRESS_FRZ_SUBMENU: { HMENU sub = CreatePopupMenu(); AppendMenu(hMenu, MF_POPUP | MF_STRING, (UINT)sub, "Freeze / Unfreeze Address"); - AppendMenu(sub, MF_STRING, 1, "Toggle state"); - AppendMenu(sub, MF_STRING, 50, "Freeze"); - AppendMenu(sub, MF_STRING, 51, "Unfreeze"); - AppendMenu(sub, MF_SEPARATOR, 52, "-"); - AppendMenu(sub, MF_STRING, 53, "Unfreeze all"); + AppendMenu(sub, MF_STRING, ID_ADDRESS_FRZ_TOGGLE_STATE, "Toggle state"); + AppendMenu(sub, MF_STRING, ID_ADDRESS_FRZ_FREEZE, "Freeze"); + AppendMenu(sub, MF_STRING, ID_ADDRESS_FRZ_UNFREEZE, "Unfreeze"); + AppendMenu(sub, MF_SEPARATOR, ID_ADDRESS_FRZ_SEP, "-"); + AppendMenu(sub, MF_STRING, ID_ADDRESS_FRZ_UNFREEZE_ALL, "Unfreeze all"); continue; } // ################################## End of SP CODE ########################### - case 2 : //We want this to give the address to add the read breakpoint for + case ID_ADDRESS_ADDBP_R: //We want this to give the address to add the read breakpoint for if((j <= CursorEndAddy) && (j >= CursorStartAddy)) sprintf(str,"Add Read Breakpoint For Address 0x%04X-0x%04X",CursorStartAddy,CursorEndAddy); else @@ -1094,14 +1107,14 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa popupmenu[i].text = str; break; - case 3 : + case ID_ADDRESS_ADDBP_W: if((j <= CursorEndAddy) && (j >= CursorStartAddy)) sprintf(str,"Add Write Breakpoint For Address 0x%04X-0x%04X",CursorStartAddy,CursorEndAddy); else sprintf(str,"Add Write Breakpoint For Address 0x%04X",j); popupmenu[i].text = str; break; - case 4 : + case ID_ADDRESS_ADDBP_X: if((j <= CursorEndAddy) && (j >= CursorStartAddy)) sprintf(str,"Add Execute Breakpoint For Address 0x%04X-0x%04X",CursorStartAddy,CursorEndAddy); else @@ -1120,7 +1133,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa } if(i != 0)i = TrackPopupMenuEx(hMenu, TPM_RETURNCMD, x, y, hMemView, NULL); switch(i){ - case 1 : //1 = Freeze Ram Address + case ID_ADDRESS_FRZ_TOGGLE_STATE: // ################################## Start of SP CODE ########################### { int n; @@ -1130,7 +1143,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa } break; } - case 50: + case ID_ADDRESS_FRZ_FREEZE: { int n; for (n=CursorStartAddy;(CursorEndAddy == -1 && n == CursorStartAddy) || n<=CursorEndAddy;n++) @@ -1139,7 +1152,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa } break; } - case 51: + case ID_ADDRESS_FRZ_UNFREEZE: { int n; for (n=CursorStartAddy;(CursorEndAddy == -1 && n == CursorStartAddy) || n<=CursorEndAddy;n++) @@ -1148,7 +1161,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa } break; } - case 53: + case ID_ADDRESS_FRZ_UNFREEZE_ALL: { int n; for (n=0;n<0x2000;n++) @@ -1164,7 +1177,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa // ################################## End of SP CODE ########################### break; - case 2 : //2 = Add Read Breakpoint + case ID_ADDRESS_ADDBP_R: watchpoint[numWPs].flags = WP_E | WP_R; if(EditingMode == 1)watchpoint[numWPs].flags |= BT_P; if((j <= CursorEndAddy) && (j >= CursorStartAddy)){ @@ -1184,7 +1197,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa else DoDebug(0); break; - case 3 : //3 = Add Write Breakpoint + case ID_ADDRESS_ADDBP_W: watchpoint[numWPs].flags = WP_E | WP_W; if(EditingMode == 1)watchpoint[numWPs].flags |= BT_P; if((j <= CursorEndAddy) && (j >= CursorStartAddy)){ @@ -1203,7 +1216,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa if(hDebug)AddBreakList(); else DoDebug(0); break; - case 4 : //4 = Add Execute Breakpoint + case ID_ADDRESS_ADDBP_X: watchpoint[numWPs].flags = WP_E | WP_X; if((j <= CursorEndAddy) && (j >= CursorStartAddy)){ watchpoint[numWPs].address = CursorStartAddy; @@ -1221,14 +1234,14 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa if(hDebug)AddBreakList(); else DoDebug(0); break; - case 5 : //5 = Go Here In Rom File + case ID_ADDRESS_SEEK_IN_ROM: ChangeMemViewFocus(2,GetNesFileAddress(j),-1); break; - case 6 : //6 = Create GG Code + case ID_ADDRESS_CREATE_GG_CODE: SetGGConvFocus(j,GetMem(j)); break; // ################################## Start of SP CODE ########################### - case 20: + case ID_ADDRESS_BOOKMARK: { if (toggleBookmark(hwnd, CursorStartAddy)) { @@ -1434,15 +1447,15 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return 0; default: - if (wParam >= 30 && wParam <= 39) + if (wParam >= ID_FIRST_BOOKMARK && wParam <= ID_FIRST_BOOKMARK) { - int newValue = handleBookmarkMenu(wParam - 30); + int newValue = handleBookmarkMenu(wParam - ID_FIRST_BOOKMARK); if (newValue != -1) { CurOffset = newValue; CursorEndAddy = -1; - CursorStartAddy = hexBookmarks[wParam - 30].address; + CursorStartAddy = hexBookmarks[wParam - ID_FIRST_BOOKMARK].address; UpdateColorTable(); } return 0; diff --git a/src/drivers/win/memviewsp.cpp b/src/drivers/win/memviewsp.cpp index 7dadf2f0..029031e0 100644 --- a/src/drivers/win/memviewsp.cpp +++ b/src/drivers/win/memviewsp.cpp @@ -68,17 +68,17 @@ BOOL CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l { case WM_INITDIALOG: // Limit bookmark descriptions to 50 characters - SendDlgItemMessage(hwndDlg,1000,EM_SETLIMITTEXT,50,0); + SendDlgItemMessage(hwndDlg,IDC_BOOKMARK_DESCRIPTION,EM_SETLIMITTEXT,50,0); // Put the current bookmark description into the edit field // and set focus to that edit field. - SetDlgItemText(hwndDlg, 1000, bookmarkDescription); - SetFocus(GetDlgItem(hwndDlg, 1000)); + SetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, bookmarkDescription); + SetFocus(GetDlgItem(hwndDlg, IDC_BOOKMARK_DESCRIPTION)); break; case WM_CLOSE: case WM_QUIT: // Update the bookmark description - GetDlgItemText(hwndDlg, 1000, bookmarkDescription, 50); + GetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, bookmarkDescription, 50); EndDialog(hwndDlg, 0); break; case WM_COMMAND: @@ -87,7 +87,7 @@ BOOL CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l case BN_CLICKED: switch(LOWORD(wParam)) { - case 1001: + case IDOK: SendMessage(hwndDlg, WM_QUIT, 0, 0); break; } @@ -185,7 +185,7 @@ void updateBookmarkMenus(HMENU menu) // Remove all bookmark menus for (i = 0;i