Win32 - Hex Editor - enabled & implemented the Save Rom As.. menu item.

This commit is contained in:
adelikat 2009-05-22 23:20:59 +00:00
parent 5f76335d65
commit 5a7de6c53f
5 changed files with 62 additions and 1 deletions

View File

@ -1,3 +1,4 @@
22-may-2009 - adelikat - win32 - Hex Editor - Save Rom As... menu option enabled and implemented
22-may-2009 - adelikat - win32 - Window caption shows the name of the ROM loaded
22-may-2009 - adelikat - win32 - Hex Editor - allowed the user to customize the color scheme by use of RGB values stored in the .cfg file
21-may-2009 - adelikat - win32 - reverted fixedFontHeight to 13 instead of 14. Gave the option of adjusting the height by modifying RowHeightBorder in the .cfg file

View File

@ -249,6 +249,37 @@ static int GetRomFileSize(){ //todo: fix or remove this?
return 0;
}
void SaveRomAs()
{
const char filter[]="NES ROM file (*.nes)\0*.nes\0";
char nameo[2048];
std::string tempName;
int x;
OPENFILENAME ofn;
memset(&ofn,0,sizeof(ofn));
ofn.lStructSize=sizeof(ofn);
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Save Nes ROM as...";
ofn.lpstrFilter=filter;
strcpy(nameo,GetRomName());
ofn.lpstrFile=nameo;
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
ofn.hwndOwner = hMemView;
if (GetSaveFileName(&ofn))
{
//if user did not add .nes, add it for them
tempName = nameo;
x = tempName.find_last_of(".nes");
if (x < 0)
tempName.append(".nes");
strcpy(nameo, tempName.c_str());
iNesSaveAs(nameo);
}
}
//should return -1, otherwise returns the line number it had the error on
int LoadTableFile(){
char str[50];
@ -1357,6 +1388,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return 0;
case MENU_MV_FILE_SAVE_AS:
SaveRomAs();
return 0;
case MENU_MV_FILE_LOAD_TBL:

View File

@ -241,7 +241,7 @@ BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Save Rom", MENU_MV_FILE_SAVE
MENUITEM "S&ave Rom As...", MENU_MV_FILE_SAVE_AS, INACTIVE
MENUITEM "S&ave Rom As...", MENU_MV_FILE_SAVE_AS
MENUITEM "&Load *.TBL File", MENU_MV_FILE_LOAD_TBL
MENUITEM "&Unload *.TBL file", MENU_MV_FILE_UNLOAD_TBL
POPUP "&Dump to file"

View File

@ -749,6 +749,33 @@ int iNesSave(){
return 1;
}
int iNesSaveAs(char* name)
{
//adelikat: TODO: iNesSave() and this have pretty much the same code, outsource the common code to a single function
FILE *fp;
if(GameInfo->type != GIT_CART)return 0;
if(GameInterface!=iNESGI)return 0;
fp = fopen(name,"wb");
int x = 0;
if (!fp)
int x = 1;
if(fwrite(&head,1,16,fp)!=16)return 0;
if(head.ROM_type&4) /* Trainer */
{
fwrite(trainerpoo,512,1,fp);
}
fwrite(ROM,0x4000,ROM_size,fp);
if(head.VROM_size)fwrite(VROM,0x2000,head.VROM_size,fp);
fclose(fp);
return 1;
}
//para edit: added function below
char *iNesShortFName() {
char *ret;

View File

@ -74,6 +74,7 @@ extern uint8 *VROM;
extern uint32 VROM_size;
extern uint32 ROM_size;
extern int iNesSave(); //bbit Edited: line added
extern int iNesSaveAs(char* name);
extern char LoadedRomFName[2048]; //bbit Edited: line added
//mbg merge 7/19/06 changed to c++ decl format