This commit is contained in:
Matthew Budd 2020-06-05 07:37:16 -04:00
commit 88e0c838e2
13 changed files with 318 additions and 93 deletions

View File

@ -63,7 +63,6 @@ char temp_chr[40] = {0};
char delimiterChar[2] = "#"; char delimiterChar[2] = "#";
extern INT_PTR CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); extern INT_PTR CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
extern char bookmarkDescription[];
MemoryMappedRegister RegNames[] = { MemoryMappedRegister RegNames[] = {
{"$2000", "PPU_CTRL"}, {"$2000", "PPU_CTRL"},
@ -857,10 +856,10 @@ void NameDebuggerBookmark(HWND hwnd)
return; return;
} else } else
{ {
char bookmarkDescription[51] = { 0 };
if (bookmarks_name[selectedItem].size()) if (bookmarks_name[selectedItem].size())
{
strcpy(bookmarkDescription, bookmarks_name[selectedItem].c_str()); strcpy(bookmarkDescription, bookmarks_name[selectedItem].c_str());
} else else
{ {
bookmarkDescription[0] = 0; bookmarkDescription[0] = 0;
// try to find the same address in bookmarks // try to find the same address in bookmarks
@ -874,7 +873,7 @@ void NameDebuggerBookmark(HWND hwnd)
} }
} }
// Show the bookmark name dialog // Show the bookmark name dialog
if (DialogBox(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB)) if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB, (LPARAM)bookmarkDescription))
{ {
// Rename the selected bookmark // Rename the selected bookmark
bookmarks_name[selectedItem] = bookmarkDescription; bookmarks_name[selectedItem] = bookmarkDescription;

View File

@ -888,7 +888,6 @@ bool WriteHeaderData(HWND hwnd, iNES_HEADER* header)
SetFocus(GetDlgItem(hwnd, IDC_MAPPER_COMBO)); SetFocus(GetDlgItem(hwnd, IDC_MAPPER_COMBO));
return false; return false;
} }
printf("mapper: %d\n", mapper);
if (mapper < 4096) if (mapper < 4096)
{ {
@ -1091,7 +1090,8 @@ bool WriteHeaderData(HWND hwnd, iNES_HEADER* header)
return false; return false;
} }
} }
else { else
{
MessageBox(hwnd, "PRG NVRAM size exceeded the limit (4096KB)", "Error", MB_OK | MB_ICONERROR); MessageBox(hwnd, "PRG NVRAM size exceeded the limit (4096KB)", "Error", MB_OK | MB_ICONERROR);
SetFocus(GetDlgItem(hwnd, IDC_PRGNVRAM_COMBO)); SetFocus(GetDlgItem(hwnd, IDC_PRGNVRAM_COMBO));
return false; return false;

View File

@ -38,6 +38,10 @@
#include "sound.h" #include "sound.h"
#include "keyscan.h" #include "keyscan.h"
#ifdef _S9XLUA_H
#include "fceulua.h"
#endif
LPDIRECTINPUT7 lpDI=0; LPDIRECTINPUT7 lpDI=0;
void InitInputPorts(bool fourscore); void InitInputPorts(bool fourscore);
@ -71,6 +75,13 @@ static void PresetImport(int preset);
static uint32 MouseData[3]; static uint32 MouseData[3];
static int32 MouseRelative[3]; static int32 MouseRelative[3];
#ifdef _S9XLUA_H
static uint32 LuaMouseData[3];
#else
static uint32* const LuaMouseData = MouseData;
#endif
//force the input types suggested by the game //force the input types suggested by the game
void ParseGIInput(FCEUGI *gi) void ParseGIInput(FCEUGI *gi)
{ {
@ -505,7 +516,13 @@ void FCEUD_UpdateInput()
if(joy) if(joy)
UpdateGamepad(false); UpdateGamepad(false);
if (mouse) GetMouseData(MouseData); if (mouse)
{
GetMouseData(MouseData);
#ifdef _S9XLUA_H
FCEU_LuaReadZapper(MouseData, LuaMouseData);
#endif
}
if (mouse_relative) GetMouseRelative(MouseRelative); if (mouse_relative) GetMouseRelative(MouseRelative);
} }
} }
@ -553,7 +570,7 @@ void InitInputPorts(bool fourscore)
InputDPtr=MouseData; InputDPtr=MouseData;
break; break;
case SI_ZAPPER: case SI_ZAPPER:
InputDPtr=MouseData; InputDPtr=LuaMouseData;
break; break;
case SI_MOUSE: case SI_MOUSE:
InputDPtr=MouseRelative; InputDPtr=MouseRelative;

View File

@ -64,7 +64,9 @@ using namespace std;
#define ID_ADDRESS_ADDBP_X 4 #define ID_ADDRESS_ADDBP_X 4
#define ID_ADDRESS_SEEK_IN_ROM 5 #define ID_ADDRESS_SEEK_IN_ROM 5
#define ID_ADDRESS_CREATE_GG_CODE 6 #define ID_ADDRESS_CREATE_GG_CODE 6
#define ID_ADDRESS_BOOKMARK 20 #define ID_ADDRESS_ADD_BOOKMARK 20
#define ID_ADDRESS_REMOVE_BOOKMARK 21
#define ID_ADDRESS_EDIT_BOOKMARK 22
#define ID_ADDRESS_SYMBOLIC_NAME 30 #define ID_ADDRESS_SYMBOLIC_NAME 30
#define BOOKMARKS_SUBMENU_POS 4 #define BOOKMARKS_SUBMENU_POS 4
@ -122,11 +124,7 @@ popupmenu[] =
{0x0000,0x3FFF, MODE_NES_PPU, ID_ADDRESS_ADDBP_W, "Add Debugger Write Breakpoint"}, {0x0000,0x3FFF, MODE_NES_PPU, ID_ADDRESS_ADDBP_W, "Add Debugger Write Breakpoint"},
{0x0000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_ADDBP_X, "Add Debugger Execute Breakpoint"}, {0x0000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_ADDBP_X, "Add Debugger Execute Breakpoint"},
{0x8000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_SEEK_IN_ROM, "Go Here In ROM File"}, {0x8000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_SEEK_IN_ROM, "Go Here In ROM File"},
{0x8000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_CREATE_GG_CODE, "Create Game Genie Code At This Address"}, {0x8000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_CREATE_GG_CODE, "Create Game Genie Code At This Address"}
{0x0000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_BOOKMARK, "Add / Remove bookmark"},
{0x0000,0xFFFF, MODE_NES_PPU, ID_ADDRESS_BOOKMARK, "Add / Remove bookmark"},
{0x0000,0xFFFF, MODE_NES_OAM, ID_ADDRESS_BOOKMARK, "Add / Remove bookmark"},
{0x0000,0xFFFF, MODE_NES_FILE, ID_ADDRESS_BOOKMARK, "Add / Remove bookmark"},
}; };
#define POPUPNUM (sizeof popupmenu / sizeof popupmenu[0]) #define POPUPNUM (sizeof popupmenu / sizeof popupmenu[0])
@ -849,7 +847,7 @@ void dumpToFile(const char* buffer, unsigned int size)
bool loadFromFile(char* buffer, unsigned int size) bool loadFromFile(char* buffer, unsigned int size)
{ {
char name[513] = {0}; char name[513] = { 0 };
OPENFILENAME ofn; OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn)); memset(&ofn, 0, sizeof(ofn));
@ -914,8 +912,73 @@ void UnfreezeAllRam() {
return; return;
} }
/*
int saveBookmarks(HWND hwnd)
{
char name[513] = { 0 };
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hInstance = fceu_hInstance;
ofn.lpstrTitle = "Save bookmarks as...";
ofn.lpstrFilter = "Bookmark list (*.bld)\0*.lst\0All Files (*.*)\0*.*\0\0";
strcpy(name, mass_replace(GetRomName(), "|", ".").c_str());
ofn.lpstrFile = name;
ofn.lpstrDefExt = "bld";
ofn.nMaxFile = 256;
ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY;
ofn.hwndOwner = hwnd;
bool success = false;
if (GetSaveFileName(&ofn))
{
FILE* bld = fopen(name, "wb");
if (bld)
{
fwrite("BOOKMARKLIST", strlen("BOOKMARKLIST"), 1, bld);
extern int storeHexPreferences(FILE*);
success = storeHexPreferences(bld);
fclose(bld);
}
}
return success;
}
int loadBookmarks(HWND hwnd)
{
char nameo[2048] = { 0 };
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hInstance = fceu_hInstance;
ofn.lpstrTitle = "Load bookmarks...";
ofn.lpstrFilter = "Bookmark list (*.bld)\0*.lst\0All Files (*.*)\0*.*\0\0";
ofn.lpstrFile = nameo;
ofn.nMaxFile = 256;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.hwndOwner = hwnd;
int success = 0;
if (GetOpenFileName(&ofn))
{
char buffer[13] = { 0 };
FILE* bld = fopen(nameo, "r");
if (bld)
{
fread(bld, strlen("BOOKMARKLIST"), 1, bld);
if (!strcpy(buffer, "BOOKMARKLIST"))
{
extern int loadHexPreferences(FILE*);
success = loadHexPreferences(bld);
}
fclose(bld);
}
}
return success;
}
*/
void FreezeRam(int address, int mode, int final){ void FreezeRam(int address, int mode, int final){
// mode: -1 == Unfreeze; 0 == Toggle; 1 == Freeze // mode: -1 == Unfreeze; 0 == Toggle; 1 == Freeze
if(FrozenAddressCount <= 256 && (address < 0x2000) || ((address >= 0x6000) && (address <= 0x7FFF))){ if(FrozenAddressCount <= 256 && (address < 0x2000) || ((address >= 0x6000) && (address <= 0x7FFF))){
@ -1198,7 +1261,6 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
HGLOBAL hGlobal ; HGLOBAL hGlobal ;
PTSTR pGlobal ; PTSTR pGlobal ;
HMENU hMenu; HMENU hMenu;
MENUITEMINFO MenuInfo;
POINT point; POINT point;
PAINTSTRUCT ps ; PAINTSTRUCT ps ;
TEXTMETRIC tm; TEXTMETRIC tm;
@ -1525,11 +1587,11 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
//sprintf(str,"x = %d, y = %d, j = %d",mousex,mousey,j); //sprintf(str,"x = %d, y = %d, j = %d",mousex,mousey,j);
//MessageBox(hMemView,str, "mouse wheel dance!", MB_OK); //MessageBox(hMemView,str, "mouse wheel dance!", MB_OK);
hMenu = CreatePopupMenu(); hMenu = CreatePopupMenu();
for(i = 0;i < POPUPNUM;i++) for(i = 0;i < POPUPNUM;i++)
{ {
if((j >= popupmenu[i].minaddress) && (j <= popupmenu[i].maxaddress) && (EditingMode == popupmenu[i].editingmode)) if((j >= popupmenu[i].minaddress) && (j <= popupmenu[i].maxaddress) && (EditingMode == popupmenu[i].editingmode))
{ {
memset(&MenuInfo,0,sizeof(MENUITEMINFO));
switch(popupmenu[i].id) switch(popupmenu[i].id)
{ {
//this will set the text for the menu dynamically based on the id //this will set the text for the menu dynamically based on the id
@ -1608,15 +1670,21 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
break; break;
} }
} }
MenuInfo.cbSize = sizeof(MENUITEMINFO); AppendMenu(hMenu, MF_STRING, popupmenu[i].id, popupmenu[i].text);
MenuInfo.fMask = MIIM_TYPE | MIIM_ID | MIIM_DATA;
MenuInfo.fType = MF_STRING;
MenuInfo.dwTypeData = popupmenu[i].text;
MenuInfo.cch = strlen(popupmenu[i].text);
MenuInfo.wID = popupmenu[i].id;
InsertMenuItem(hMenu,i+1,1,&MenuInfo);
} }
} }
// Add / Edit / Remove bookmark
int foundBookmark = findBookmark(CursorStartAddy, EditingMode);
if (foundBookmark != -1)
{
AppendMenu(hMenu, MF_STRING, ID_ADDRESS_EDIT_BOOKMARK, "Edit Bookmark");
AppendMenu(hMenu, MF_STRING, ID_ADDRESS_REMOVE_BOOKMARK, "Remove Bookmark");
}
else
AppendMenu(hMenu, MF_STRING, ID_ADDRESS_ADD_BOOKMARK, "Add Bookmark");
if (i != 0) if (i != 0)
i = TrackPopupMenuEx(hMenu, TPM_RETURNCMD | TPM_RIGHTBUTTON, x, y, hMemView, NULL); i = TrackPopupMenuEx(hMenu, TPM_RETURNCMD | TPM_RIGHTBUTTON, x, y, hMemView, NULL);
switch(i) switch(i)
@ -1766,19 +1834,59 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case ID_ADDRESS_CREATE_GG_CODE: case ID_ADDRESS_CREATE_GG_CODE:
SetGGConvFocus(j,GetMem(j)); SetGGConvFocus(j,GetMem(j));
break; break;
case ID_ADDRESS_BOOKMARK: case ID_ADDRESS_ADD_BOOKMARK:
{ {
if (toggleBookmark(hwnd, CursorStartAddy, EditingMode)) if (foundBookmark == -1)
{ {
MessageBox(hDebug, "Can't set more than 64 bookmarks", "Error", MB_OK | MB_ICONERROR); if (nextBookmark >= 64)
} MessageBox(hwnd, "Can't set more than 64 bookmarks.", "Error", MB_OK | MB_ICONERROR);
else else
{ {
updateBookmarkMenus(GetSubMenu(GetMenu(hwnd), BOOKMARKS_SUBMENU_POS)); int ret = addBookmark(hwnd, CursorStartAddy, EditingMode);
UpdateColorTable(); if (ret == -1)
MessageBox(hwnd, "Error adding bookmark.", "Error", MB_OK | MB_ICONERROR);
else if (ret == 0)
{
updateBookmarkMenus(GetSubMenu(GetMenu(hwnd), BOOKMARKS_SUBMENU_POS));
UpdateColorTable();
}
}
} }
else // usually it cannot reach here.
MessageBox(hwnd, "This address already has a bookmark.", "Error", MB_OK | MB_ICONERROR);
break; break;
} }
case ID_ADDRESS_EDIT_BOOKMARK:
if (foundBookmark != -1)
{
int ret = editBookmark(hwnd, foundBookmark);
if (ret == -1)
MessageBox(hwnd, "Error editing bookmark.", "Error", MB_OK | MB_ICONERROR);
else if (ret == 0)
{
updateBookmarkMenus(GetSubMenu(GetMenu(hwnd), BOOKMARKS_SUBMENU_POS));
UpdateColorTable();
}
}
else // usually it cannot reach here.
MessageBox(hwnd, "This address doesn't have a bookmark.", "Error", MB_OK | MB_ICONERROR);
break;
case ID_ADDRESS_REMOVE_BOOKMARK:
if (foundBookmark != -1)
{
int ret = removeBookmark(foundBookmark);
if (ret == -1)
MessageBox(hwnd, "Error removing bookmark.", "Error", MB_OK | MB_ICONERROR);
else if (ret == 0)
{
updateBookmarkMenus(GetSubMenu(GetMenu(hwnd), BOOKMARKS_SUBMENU_POS));
UpdateColorTable();
}
}
else
// usually it cannot reach here.
MessageBox(hwnd, "This address doesn't have a bookmark.", "Error", MB_OK | MB_ICONERROR);
break;
case ID_ADDRESS_SYMBOLIC_NAME: case ID_ADDRESS_SYMBOLIC_NAME:
{ {
if (DoSymbolicDebugNaming(j, hMemView)) if (DoSymbolicDebugNaming(j, hMemView))
@ -2117,14 +2225,22 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case MENU_MV_BOOKMARKS_RM_ALL: case MENU_MV_BOOKMARKS_RM_ALL:
if (nextBookmark) if (nextBookmark)
{ {
if (MessageBox(hwnd, "Remove All Bookmarks?", "Bookmarks", MB_YESNO) == IDYES) if (MessageBox(hwnd, "Remove All Bookmarks?", "Bookmarks", MB_YESNO | MB_ICONINFORMATION) == IDYES)
{ {
removeAllBookmarks(GetSubMenu(GetMenu(hwnd), BOOKMARKS_SUBMENU_POS)); removeAllBookmarks(GetSubMenu(GetMenu(hwnd), BOOKMARKS_SUBMENU_POS));
UpdateColorTable(); UpdateColorTable();
} }
} }
return 0; return 0;
/*
case MENU_MV_BOOKMARKS_EXPORT:
if (!saveBookmarks(hwnd))
MessageBox(hwnd, "Error saving bookmarks.", "Error", MB_OK | MB_ICONERROR);
return 0;
case MENU_MV_BOOKMARKS_IMPORT:
loadBookmarks(hwnd);
return 0;
*/
case MENU_MV_HELP: case MENU_MV_HELP:
OpenHelpWindow(memviewhelp); OpenHelpWindow(memviewhelp);
return 0; return 0;
@ -2201,7 +2317,11 @@ void DoMemView()
wndclass.lpszMenuName = "MEMVIEWMENU"; wndclass.lpszMenuName = "MEMVIEWMENU";
wndclass.lpszClassName = "MEMVIEW"; wndclass.lpszClassName = "MEMVIEW";
if(!RegisterClassEx(&wndclass)) {FCEUD_PrintError("Error Registering MEMVIEW Window Class."); return;} if(!RegisterClassEx(&wndclass))
{
FCEUD_PrintError("Error Registering MEMVIEW Window Class.");
return;
}
hMemView = CreateWindowEx(0,"MEMVIEW","Memory Editor", hMemView = CreateWindowEx(0,"MEMVIEW","Memory Editor",
//WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS, /* Style */ //WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS, /* Style */

View File

@ -4,7 +4,10 @@ void UpdateMemoryView(int draw_all);
void UpdateColorTable(); void UpdateColorTable();
void ChangeMemViewFocus(int newEditingMode, int StartOffset,int EndOffset); void ChangeMemViewFocus(int newEditingMode, int StartOffset,int EndOffset);
void UpdateCaption(); void UpdateCaption();
/*
int saveBookmarks(HWND hwnd);
int loadBookmarks(HWND hwnd);
*/
void ApplyPatch(int addr,int size, uint8* data); void ApplyPatch(int addr,int size, uint8* data);
void UndoLastPatch(); void UndoLastPatch();
@ -13,5 +16,4 @@ void SetHexEditorAddress(int gotoaddress);
extern HWND hMemView, hMemFind; extern HWND hMemView, hMemFind;
extern int EditingMode; extern int EditingMode;
extern char EditString[4][20]; extern char EditString[4][20];

View File

@ -52,13 +52,13 @@ int findBookmark(unsigned int address, int editmode)
return -1; return -1;
} }
char bookmarkDescription[51] = {0};
BOOL CenterWindow(HWND hwndDlg); BOOL CenterWindow(HWND hwndDlg);
/// Callback function for the name bookmark dialog /// Callback function for the name bookmark dialog
INT_PTR CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) INT_PTR CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
static char* description;
switch (uMsg) switch (uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
@ -67,7 +67,9 @@ INT_PTR CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
// Put the current bookmark description into the edit field // Put the current bookmark description into the edit field
// and set focus to that edit field. // and set focus to that edit field.
SetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, bookmarkDescription);
description = (char*)lParam;
SetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, description);
SetFocus(GetDlgItem(hwndDlg, IDC_BOOKMARK_DESCRIPTION)); SetFocus(GetDlgItem(hwndDlg, IDC_BOOKMARK_DESCRIPTION));
break; break;
case WM_CLOSE: case WM_CLOSE:
@ -83,7 +85,7 @@ INT_PTR CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
case IDOK: case IDOK:
{ {
// Update the bookmark description // Update the bookmark description
GetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, bookmarkDescription, 50); GetDlgItemText(hwndDlg, IDC_BOOKMARK_DESCRIPTION, description, 50);
EndDialog(hwndDlg, 1); EndDialog(hwndDlg, 1);
break; break;
} }
@ -99,38 +101,63 @@ INT_PTR CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
/// @param hwnd HWND of the FCEU window /// @param hwnd HWND of the FCEU window
/// @param address Address of the new bookmark /// @param address Address of the new bookmark
/// @param editmode The editing mode of the hex editor (RAM/PPU/OAM/ROM) /// @param editmode The editing mode of the hex editor (RAM/PPU/OAM/ROM)
/// @return Returns 0 if everything's OK and an error flag otherwise. /// @return Returns 0 if everything's OK, 1 if user canceled and an error flag otherwise.
int addBookmark(HWND hwnd, unsigned int address, int editmode) int addBookmark(HWND hwnd, unsigned int address, int editmode)
{ {
// Enforce a maximum of 64 bookmarks // Enforce a maximum of 64 bookmarks
if (nextBookmark < 64) if (nextBookmark < 64)
{ {
sprintf(bookmarkDescription, "%s %04X", EditString[editmode], address); char description[51] = { 0 };
sprintf(description, "%s %04X", EditString[editmode], address);
// Show the bookmark name dialog // Show the bookmark name dialog
DialogBox(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB); if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB, (LPARAM)description))
{
// Update the bookmark description // Add the bookmark
hexBookmarks[nextBookmark].address = address; hexBookmarks[nextBookmark].address = address;
hexBookmarks[nextBookmark].editmode = editmode; hexBookmarks[nextBookmark].editmode = editmode;
strcpy(hexBookmarks[nextBookmark].description, bookmarkDescription); strcpy(hexBookmarks[nextBookmark].description, description);
nextBookmark++;
nextBookmark++; return 0;
}
else
return 1;
}
else
return -1;
}
/// Edit a bookmark in the bookmark list
/// @param hwnd HWND of the FCEU window
/// @param index Index of the bookmark to edit
/// @return Returns 0 if everything's OK, 1 if user canceled and an error flag otherwise.
int editBookmark(HWND hwnd, unsigned int index)
{
if (index >= 64) return -1;
char description[51] = { 0 };
strcpy(description, hexBookmarks[index].description);
// Show the bookmark name dialog
if (DialogBoxParam(fceu_hInstance, "NAMEBOOKMARKDLG", hwnd, nameBookmarkCallB, (LPARAM)description))
{
// Update the bookmark information
strcpy(hexBookmarks[index].description, description);
return 0; return 0;
} }
else else
{
return 1; return 1;
}
return -1;
} }
/// Removes a bookmark from the bookmark list /// Removes a bookmark from the bookmark list
/// @param index Index of the bookmark to remove /// @param index Index of the bookmark to remove
void removeBookmark(unsigned int index) /// @return Returns 0 if everything's OK, 1 if user canceled and an error flag otherwise.
int removeBookmark(unsigned int index)
{ {
// TODO: Range checking if (index >= 64) return -1;
// At this point it's necessary to move the content of the bookmark list // At this point it's necessary to move the content of the bookmark list
for (int i=index;i<nextBookmark - 1;i++) for (int i=index;i<nextBookmark - 1;i++)
{ {
@ -138,8 +165,10 @@ void removeBookmark(unsigned int index)
} }
--nextBookmark; --nextBookmark;
}
return 0;
}
/*
/// Adds or removes a bookmark from a given address /// Adds or removes a bookmark from a given address
/// @param hwnd HWND of the emu window /// @param hwnd HWND of the emu window
/// @param address Address of the bookmark /// @param address Address of the bookmark
@ -159,35 +188,28 @@ int toggleBookmark(HWND hwnd, uint32 address, int editmode)
return 0; return 0;
} }
} }
*/
/// Updates the bookmark menu in the hex window /// Updates the bookmark menu in the hex window
/// @param menu Handle of the bookmark menu /// @param menu Handle of the bookmark menu
void updateBookmarkMenus(HMENU menu) void updateBookmarkMenus(HMENU menu)
{ {
int i;
MENUITEMINFO mi;
mi.cbSize = sizeof(MENUITEMINFO);
mi.fMask = MIIM_TYPE | MIIM_ID | MIIM_DATA;
mi.fType = MF_STRING;
// Remove all bookmark menus // Remove all bookmark menus
for (i = 0;i<nextBookmark + 1;i++) for (int i = 0; i<nextBookmark + 1; i++)
{
RemoveMenu(menu, ID_FIRST_BOOKMARK + i, MF_BYCOMMAND); RemoveMenu(menu, ID_FIRST_BOOKMARK + i, MF_BYCOMMAND);
} RemoveMenu(menu, ID_BOOKMARKLIST_SEP, MF_BYCOMMAND);
// Add the menus again if (nextBookmark != 0)
for (i = 0;i<nextBookmark;i++)
{ {
// Get the text of the menu // Add the menus again
char buffer[0x100]; AppendMenu(menu, MF_SEPARATOR, ID_BOOKMARKLIST_SEP, NULL);
sprintf(buffer, i < 10 ? "&%d. $%04X - %s\tCtrl+%d" : "%d. $%04X - %s",i, hexBookmarks[i].address, hexBookmarks[i].description, i); for (int i = 0;i<nextBookmark;i++)
{
// Get the text of the menu
char buffer[0x100];
sprintf(buffer, i < 10 ? "&%d. $%04X - %s\tCtrl+%d" : "%d. $%04X - %s",i, hexBookmarks[i].address, hexBookmarks[i].description, i);
mi.dwTypeData = buffer; AppendMenu(menu, MF_STRING, ID_FIRST_BOOKMARK + i, buffer);
mi.cch = strlen(buffer); }
mi.wID = ID_FIRST_BOOKMARK + i;
InsertMenuItem(menu, 2 + i , TRUE, &mi);
} }
} }
@ -212,6 +234,7 @@ void removeAllBookmarks(HMENU menu)
{ {
RemoveMenu(menu, ID_FIRST_BOOKMARK + i, MF_BYCOMMAND); RemoveMenu(menu, ID_FIRST_BOOKMARK + i, MF_BYCOMMAND);
} }
RemoveMenu(menu, ID_BOOKMARKLIST_SEP, MF_BYCOMMAND);
nextBookmark = 0; nextBookmark = 0;
} }

View File

@ -21,6 +21,7 @@
#include "types.h" #include "types.h"
#define ID_FIRST_BOOKMARK 30 #define ID_FIRST_BOOKMARK 30
#define ID_BOOKMARKLIST_SEP (ID_FIRST_BOOKMARK - 1)
typedef struct typedef struct
{ {
@ -32,8 +33,11 @@ typedef struct
extern HexBookmark hexBookmarks[64]; extern HexBookmark hexBookmarks[64];
extern int nextBookmark; extern int nextBookmark;
int toggleBookmark(HWND hwnd, uint32 address, int mode); int findBookmark(unsigned int address, int editmode);
int addBookmark(HWND hwnd, unsigned int address, int editmode);
int editBookmark(HWND hwnd, unsigned int index);
int removeBookmark(unsigned int index);
// int toggleBookmark(HWND hwnd, uint32 address, int mode);
void updateBookmarkMenus(HMENU menu); void updateBookmarkMenus(HMENU menu);
int handleBookmarkMenu(int bookmark); int handleBookmarkMenu(int bookmark);
void removeAllBookmarks(HMENU menu); void removeAllBookmarks(HMENU menu);

View File

@ -797,19 +797,21 @@ INT_PTR CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
addrCtrlID = IDC_EDIT_COMPAREADDRESS; addrCtrlID = IDC_EDIT_COMPAREADDRESS;
// limit the length to 4 since currently doesn't support batch editing // limit the length to 4 since currently doesn't support batch editing
SendDlgItemMessage(hDlg, addrCtrlID, EM_SETLIMITTEXT, 4, 0); SendDlgItemMessage(hDlg, addrCtrlID, EM_SETLIMITTEXT, 4, 0);
strcpy(title, "Edit "); strcpy(title, "Edit");
break; break;
case WATCHER_MSG_ADD: case WATCHER_MSG_ADD:
strcpy(title, "Add "); strcpy(title, "Add");
addrCtrlID = IDC_EDIT_COMPAREADDRESSES; addrCtrlID = IDC_EDIT_COMPAREADDRESSES;
break; break;
case WATCHER_MSG_DUP: case WATCHER_MSG_DUP:
default: default:
strcpy(title, "Duplicate "); strcpy(title, "Duplicate");
addrCtrlID = IDC_EDIT_COMPAREADDRESSES; addrCtrlID = IDC_EDIT_COMPAREADDRESSES;
break; break;
} }
strcat(title, " ");
// The information is needed to fill to the UI, and separetor doesn't have them // The information is needed to fill to the UI, and separetor doesn't have them
if (msg->Type != 'S') if (msg->Type != 'S')
{ {

View File

@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}} //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。 // Microsoft Visual C++ generated include file.
// 供 res.rc 使用 // Used for res.rc
// //
#define CLOSE_BUTTON 1 #define CLOSE_BUTTON 1
#define BUTTON_CLOSE 1 #define BUTTON_CLOSE 1

View File

@ -72,6 +72,7 @@ void FCEU_ReloadLuaCode();
void FCEU_LuaStop(); void FCEU_LuaStop();
int FCEU_LuaRunning(); int FCEU_LuaRunning();
void FCEU_LuaReadZapper(const uint32* mouse_in, uint32* mouse_out);
uint8 FCEU_LuaReadJoypad(int,uint8); // HACK - Function needs controller input uint8 FCEU_LuaReadJoypad(int,uint8); // HACK - Function needs controller input
int FCEU_LuaSpeed(); int FCEU_LuaSpeed();
int FCEU_LuaFrameskip(); int FCEU_LuaFrameskip();

View File

@ -208,6 +208,11 @@ static int wasPaused = FALSE;
// Transparency strength. 255=opaque, 0=so transparent it's invisible // Transparency strength. 255=opaque, 0=so transparent it's invisible
static int transparencyModifier = 255; static int transparencyModifier = 255;
// Our zapper.
static int luazapperx = -1;
static int luazappery = -1;
static int luazapperfire = -1;
// Our joypads. // Our joypads.
static uint8 luajoypads1[4]= { 0xFF, 0xFF, 0xFF, 0xFF }; //x1 static uint8 luajoypads1[4]= { 0xFF, 0xFF, 0xFF, 0xFF }; //x1
static uint8 luajoypads2[4]= { 0x00, 0x00, 0x00, 0x00 }; //0x static uint8 luajoypads2[4]= { 0x00, 0x00, 0x00, 0x00 }; //0x
@ -278,6 +283,9 @@ static const char* toCString(lua_State* L, int idx=0);
static void FCEU_LuaOnStop() static void FCEU_LuaOnStop()
{ {
luaRunning = FALSE; luaRunning = FALSE;
luazapperx = -1;
luazappery = -1;
luazapperfire = -1;
for (int i = 0 ; i < 4 ; i++ ){ for (int i = 0 ; i < 4 ; i++ ){
luajoypads1[i]= 0xFF; // Set these back to pass-through luajoypads1[i]= 0xFF; // Set these back to pass-through
luajoypads2[i]= 0x00; luajoypads2[i]= 0x00;
@ -2536,7 +2544,37 @@ static int zapper_read(lua_State *L){
return 1; return 1;
} }
// zapper.set(table state)
//
// Sets the zapper state for the next frame advance.
static int zapper_set(lua_State* L) {
luaL_checktype(L, 1, LUA_TTABLE);
luazapperx = -1;
luazappery = -1;
luazapperfire = -1;
lua_getfield(L, 1, "x");
if (!lua_isnil(L, -1)) luazapperx = lua_tointeger(L, -1);
lua_pop(L, 1);
lua_getfield(L, 1, "y");
if (!lua_isnil(L, -1)) luazappery = lua_tointeger(L, -1);
lua_pop(L, 1);
lua_getfield(L, 1, "fire");
if (!lua_isnil(L, -1))
{
if (lua_toboolean(L, -1)) // True or string
luazapperfire = 1;
if (lua_toboolean(L, -1) == 0 || lua_isstring(L, -1)) // False or string
luazapperfire = 0;
}
lua_pop(L, 1);
return 0;
}
// table joypad.read(int which = 1) // table joypad.read(int which = 1)
// //
@ -5815,6 +5853,7 @@ static const struct luaL_reg joypadlib[] = {
static const struct luaL_reg zapperlib[] = { static const struct luaL_reg zapperlib[] = {
{"read", zapper_read}, {"read", zapper_read},
{"set", zapper_set},
{NULL,NULL} {NULL,NULL}
}; };
@ -6309,6 +6348,15 @@ int FCEU_LuaRunning() {
return (int) (L != NULL); // should return true if callback functions are active. return (int) (L != NULL); // should return true if callback functions are active.
} }
/**
* Applies zapper.set overrides to zapper input.
*/
void FCEU_LuaReadZapper(const uint32* mouse_in, uint32* mouse_out)
{
mouse_out[0] = luazapperx >= 0 ? luazapperx : mouse_in[0];
mouse_out[1] = luazappery >= 0 ? luazappery : mouse_in[1];
mouse_out[2] = luazapperfire >= 0 ? (luazapperfire | (mouse_in[2] & ~1)) : mouse_in[2];
}
/** /**
* Returns true if Lua would like to steal the given joypad control. * Returns true if Lua would like to steal the given joypad control.

View File

@ -79,14 +79,14 @@
<li><a href="http://sourceforge.net/projects/fceultra/files/Source%20Code/2.2.3%20src/fceux-2.2.3.src.tar.gz/download">FCEUX 2.2.3 src</a></li> <li><a href="http://sourceforge.net/projects/fceultra/files/Source%20Code/2.2.3%20src/fceux-2.2.3.src.tar.gz/download">FCEUX 2.2.3 src</a></li>
</ul> </ul>
<p>If you are working with a developer to fix an issue affecting you then this is where you will find your fixed build. It may potentially be out of date.</p> <p>If you are working with a developer to fix an issue affecting you then this is where you will find your fixed build:</p>
<ul><li><a href="http://fceux.com/zip">Interim Build $WCREV$</a> $WCDATE$</li></ul> <ul><li><a href="https://ci.appveyor.com/project/zeromus/fceux/build/artifacts">Interim Build</a></li></ul>
<h3>Source Code</h3> <h3>Source Code</h3>
<ul> <ul>
<li><a href="http://sourceforge.net/p/fceultra/code/">SVN repository</a></li> <li><a href="https://github.com/TASVideos/fceux">Git repository</a></li>
</ul> </ul>
<p>FCEUX development is done commited to a subversion repository hosted at sourceforge. The last version of the source can be found there.</p> <p>FCEUX development is done commited to a Git repository hosted at Github. The last version of the source can be found there.</p>
<h4>Compiling</h4> <h4>Compiling</h4>
<ul> <ul>
<li>Win32 uses MS Visual Studio 2010. Newer versions of visual studio should be able to build it, with a little trouble.</li> <li>Win32 uses MS Visual Studio 2010. Newer versions of visual studio should be able to build it, with a little trouble.</li>

View File

@ -418,8 +418,17 @@
<p><span class="rvts37"><br/></span></p> <p><span class="rvts37"><br/></span></p>
<p><span class="rvts37">The return table consists of 3 values: x, y, and fire. &nbsp;x and y are the x,y coordinates of the zapper target in terms of pixels. &nbsp;fire represents the zapper firing. &nbsp;0 = not firing, 1 = firing</span></p> <p><span class="rvts37">The return table consists of 3 values: x, y, and fire. &nbsp;x and y are the x,y coordinates of the zapper target in terms of pixels. &nbsp;fire represents the zapper firing. &nbsp;0 = not firing, 1 = firing</span></p>
<p><span class="rvts37"><br/></span></p> <p><span class="rvts37"><br/></span></p>
<p><span class="rvts64">zapper.set(table input)</span></p>
<p><span class="rvts37"><br/></span></p> <p><span class="rvts37"><br/></span></p>
<p><span class="rvts37">Note: The zapper is always controller 2 on the NES so there is no player argument to this function.</span></p> <p><span class="rvts37">Sets the zapper input state.</span></p>
<p><span class="rvts37"><br/></span></p>
<p><span class="rvts37">Taple entries (nil or -1 to leave unaffected):</span></p>
<p><span class="rvts37">x &nbsp; &nbsp;- Forces the X position </span></p>
<p><span class="rvts37">y &nbsp; &nbsp;- Forces the Y position</span></p>
<p><span class="rvts37">fire - Forces trigger (true/1 on, false/0 off)</span></p>
<p><span class="rvts37"><br/></span></p>
<p><span class="rvts37"><br/></span></p>
<p><span class="rvts37">Note: The zapper is always controller 2 on the NES so there is no player argument to these functions.</span></p>
<p><span class="rvts37"><br/></span></p> <p><span class="rvts37"><br/></span></p>
<p><span class="rvts37"><br/></span></p> <p><span class="rvts37"><br/></span></p>
<p><span class="rvts71">Input Library</span></p> <p><span class="rvts71">Input Library</span></p>