/* FCEUXD SP - NES/Famicom Emulator * * Copyright notice for this file: * Copyright (C) 2005 Sebastian Porst * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include "debuggersp.h" #include "memviewsp.h" #include "common.h" #include "debugger.h" #include "../../debug.h" extern char symbDebugEnabled; /** * Stores debugger preferences in a file * * @param f File to write the preferences to * @return 0 if everything went fine. An error code if something went wrong. **/ int storeDebuggerPreferences(FILE* f) { int i; // Flag that says whether symbolic debugging should be enabled if (fwrite(&symbDebugEnabled, 1, 1, f) != 1) return 1; // Write the number of active CPU bookmarks if (fwrite(&bookmarks, sizeof(unsigned int), 1, f) != 1) return 1; // Write the addresses of those bookmarks if (fwrite(bookmarkData, sizeof(unsigned short), bookmarks, f) != bookmarks) return 1; // Write all breakpoints for (i=0;i<65;i++) { unsigned int len; // Write the start address of a BP if (fwrite(&watchpoint[i].address, sizeof(watchpoint[i].address), 1, f) != 1) return 1; // Write the end address of a BP if (fwrite(&watchpoint[i].endaddress, sizeof(watchpoint[i].endaddress), 1, f) != 1) return 1; // Write the flags of a BP if (fwrite(&watchpoint[i].flags, sizeof(watchpoint[i].flags), 1, f) != 1) return 1; // Write the length of the BP condition len = watchpoint[i].condText ? strlen(watchpoint[i].condText) : 0; if (fwrite(&len, sizeof(len), 1, f) != 1) return 1; // Write the text of the BP condition if (len) { if (fwrite(watchpoint[i].condText, 1, len, f) != len) return 1; } len = watchpoint[i].desc ? strlen(watchpoint[i].desc) : 0; // Write the length of the BP description if (fwrite(&len, sizeof(len), 1, f) != 1) return 1; // Write the actual BP description if (len) { if (fwrite(watchpoint[i].desc, 1, len, f) != len) return 1; } } return 0; } /** * Stores the preferences from the Hex window * * @param f File to write the preferences to * @return 0 if everything went fine. An error code if something went wrong. **/ int storeHexPreferences(FILE* f) { int i; // Writes the number of bookmarks to save if (fwrite(&nextBookmark, sizeof(nextBookmark), 1, f) != 1) return 1; for (i=0;i