From afbdc4f5971e4d17b0c2e3589a1fd7f928d1db3d Mon Sep 17 00:00:00 2001 From: Zero Date: Wed, 16 Nov 2022 03:44:35 -0500 Subject: [PATCH] Add checksum skip checkbox to settings window --- flips-gtk.cpp | 17 +++++++++++++---- flips-w32.cpp | 17 ++++++++++++----- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/flips-gtk.cpp b/flips-gtk.cpp index b4eddb3..fb86493 100644 --- a/flips-gtk.cpp +++ b/flips-gtk.cpp @@ -356,7 +356,7 @@ static void ApplyPatchMultiAutoSub(gpointer data, gpointer user_data) gchar * outrompath=g_strndup(patchpath, strlen(patchpath)+strlen(romext)+1); strcpy(GetExtension(outrompath), romext); - struct errorinfo errinf=ApplyPatchMem(patch, rompath, true, outrompath, NULL, true); + struct errorinfo errinf=ApplyPatchMem(patch, rompath, !cfg.getint("skipchecksum"), outrompath, NULL, true); if (errinf.level==el_broken) error(ea_invalid); if (errinf.level==el_notthis) error(ea_no_auto); if (errinf.level==el_warning) error(ea_warning); @@ -433,7 +433,7 @@ static void ApplyPatchMulti(gpointer data, gpointer user_data) char * outromext=GetExtension(outromname); strcpy(outromext, state->romext); - struct errorinfo errinf=ApplyPatchMem2(patch, state->rommem, state->removeHeaders, true, outromname, NULL); + struct errorinfo errinf=ApplyPatchMem2(patch, state->rommem, state->removeHeaders, !cfg.getint("skipchecksum"), outromname, NULL); if (errinf.level==el_broken) error(e_invalid); if (errinf.level==el_notthis) error(e_invalid_this); if (errinf.level==el_warning) error(e_warning); @@ -486,7 +486,7 @@ static void a_ApplyPatch(GtkButton* widget, gpointer user_data) char * outromname=SelectRom(outromname_d, "Select Output File", true); if (outromname) { - struct errorinfo errinf=ApplyPatchMem(patchfile, inromname, true, outromname, NULL, cfg.getint("autorom")); + struct errorinfo errinf=ApplyPatchMem(patchfile, inromname, !cfg.getint("skipchecksum"), outromname, NULL, cfg.getint("autorom")); ShowMessage(errinf); } g_free(inromname); @@ -677,7 +677,7 @@ static void a_ApplyRun(GtkButton* widget, gpointer user_data) else outromname=g_file_get_uri(outrom_file); g_object_unref(outrom_file); - struct errorinfo errinf=ApplyPatchMem(patchfile, romname, true, outromname, NULL, cfg.getint("autorom")); + struct errorinfo errinf=ApplyPatchMem(patchfile, romname, !cfg.getint("skipchecksum"), outromname, NULL, cfg.getint("autorom")); if (errinf.level!=el_ok) ShowMessage(errinf); if (errinf.level>=el_notthis) goto cleanup; @@ -763,6 +763,13 @@ static void a_ShowSettings(GtkButton* widget, gpointer user_data) gtk_grid_attach(grid, autoRom, 0,3, 1,1); flatpakDisable(autoRom); + GtkWidget* skipChecksum; + skipChecksum=gtk_check_button_new_with_mnemonic("Ignore checksum when patching"); + if (cfg.getint("skipchecksum")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(skipChecksum), true); + g_object_ref(skipChecksum); + gtk_grid_attach(grid, skipChecksum, 0,4, 1,1); + flatpakDisable(skipChecksum); + gtk_container_add(GTK_CONTAINER(settingswindow), GTK_WIDGET(grid)); gtk_widget_show_all(settingswindow); @@ -770,8 +777,10 @@ static void a_ShowSettings(GtkButton* widget, gpointer user_data) cfg.setint("assocemu", (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(emuAssoc)))); cfg.setint("autorom", (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(autoRom)))); + cfg.setint("skipchecksum", (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(skipChecksum)))); g_object_unref(emuAssoc); g_object_unref(autoRom); + g_object_unref(skipChecksum); } static gboolean filterExecOnly(const GtkFileFilterInfo* filter_info, gpointer data) diff --git a/flips-w32.cpp b/flips-w32.cpp index 771984e..ee84a23 100644 --- a/flips-w32.cpp +++ b/flips-w32.cpp @@ -90,6 +90,7 @@ struct { unsigned char lastRomType; bool openInEmulatorOnAssoc; bool enableAutoRomSelector; + bool skipChecksum; enum patchtype lastPatchType; int windowleft; int windowtop; @@ -264,7 +265,7 @@ int a_ApplyPatch(LPCWSTR clipatchname) if (*inromext && *outromext) wcscpy(outromext, inromext); } if (!SelectRom(outromname, TEXT("Select Output File"), true)) goto cancel; - struct errorinfo errinf=ApplyPatchMem(patch, inromname, true, outromname, NULL, state.enableAutoRomSelector); + struct errorinfo errinf=ApplyPatchMem(patch, inromname, !state.skipChecksum, outromname, NULL, state.enableAutoRomSelector); delete patch; MessageBoxA(hwndMain, errinf.description, flipsversion, mboxtype[errinf.level]); return errinf.level; @@ -334,7 +335,7 @@ int a_ApplyPatch(LPCWSTR clipatchname) if (foundRom!=romname) canUseFoundRom=false; wcscpy(GetExtension(thisFileName), GetExtension(romname)); - struct errorinfo errinf=ApplyPatchMem(patch, romname, true, thisFileNameWithPath, NULL, true); + struct errorinfo errinf=ApplyPatchMem(patch, romname, !state.skipChecksum, thisFileNameWithPath, NULL, true); if (errinf.level==el_broken) worsterror=max(worsterror, e_invalid); if (errinf.level==el_notthis) worsterror=max(worsterror, e_no_auto); @@ -410,7 +411,7 @@ int a_ApplyPatch(LPCWSTR clipatchname) { LPWSTR patchExtension=GetExtension(thisFileName); wcscpy(patchExtension, romExtension); - struct errorinfo errinf=ApplyPatchMem2(patch, inrom, removeheaders, true, thisFileNameWithPath, NULL); + struct errorinfo errinf=ApplyPatchMem2(patch, inrom, removeheaders, !state.skipChecksum, thisFileNameWithPath, NULL); if (errinf.level==el_broken) worsterror=max(worsterror, e_invalid); if (errinf.level==el_notthis) worsterror=max(worsterror, e_invalid_this); @@ -566,7 +567,7 @@ int a_ApplyRun(LPCWSTR clipatchname) WCHAR outfilename[MAX_PATH]; GetFullPathName(outfilename_rel, MAX_PATH, outfilename, NULL); - errinf=ApplyPatchMem(patch, romname, true, outfilename, NULL, state.enableAutoRomSelector); + errinf=ApplyPatchMem(patch, romname, !state.skipChecksum, outfilename, NULL, state.enableAutoRomSelector); error: if (errinf.level!=el_ok) MessageBoxA(hwndMain, errinf.description, flipsversion, mboxtype[errinf.level]); @@ -616,7 +617,7 @@ void a_ShowSettings() hwndSettings=CreateWindowA( "floatingmunchers", flipsversion, WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_BORDER|WS_MINIMIZEBOX, - CW_USEDEFAULT, CW_USEDEFAULT, 3+6+202+6+3, 21 + 6+23+6+23+3+13+1+17+4+17+6 + 3, NULL, NULL, GetModuleHandle(NULL), NULL); + CW_USEDEFAULT, CW_USEDEFAULT, 3+6+202+6+3, 21 + 6+23+6+23+3+13+1+17+4+17+6 + 3+17+6 + 3, NULL, NULL, GetModuleHandle(NULL), NULL); HFONT hfont=(HFONT)GetStockObject(DEFAULT_GUI_FONT); HWND item; @@ -674,6 +675,10 @@ void a_ShowSettings() check("Enable automatic ROM selector", 202, 17, 105); Button_SetCheck(item, (state.enableAutoRomSelector)); endline(3); + line(17); + check("Ignore checksum when patching", 202, 17, 106); Button_SetCheck(item, (state.skipChecksum)); + endline(3); + ShowWindow(hwndSettings, SW_SHOW); #undef firstbutton #undef button @@ -782,6 +787,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (wParam==103) state.openInEmulatorOnAssoc=false; if (wParam==104) state.openInEmulatorOnAssoc=true; if (wParam==105) state.enableAutoRomSelector^=1; + if (wParam==106) state.skipChecksum^=1; } break; case WM_CLOSE: @@ -934,6 +940,7 @@ void GUILoadConfig() state.lastRomType=0; state.openInEmulatorOnAssoc=false; state.enableAutoRomSelector=false; + state.skipChecksum=false; state.lastPatchType=ty_bps; state.windowleft=CW_USEDEFAULT; state.windowtop=CW_USEDEFAULT;