Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit afbdc4f

Browse files
committed
Add checksum skip checkbox to settings window
1 parent ce2e7ca commit afbdc4f

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

flips-gtk.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ static void ApplyPatchMultiAutoSub(gpointer data, gpointer user_data)
356356
gchar * outrompath=g_strndup(patchpath, strlen(patchpath)+strlen(romext)+1);
357357
strcpy(GetExtension(outrompath), romext);
358358

359-
struct errorinfo errinf=ApplyPatchMem(patch, rompath, true, outrompath, NULL, true);
359+
struct errorinfo errinf=ApplyPatchMem(patch, rompath, !cfg.getint("skipchecksum"), outrompath, NULL, true);
360360
if (errinf.level==el_broken) error(ea_invalid);
361361
if (errinf.level==el_notthis) error(ea_no_auto);
362362
if (errinf.level==el_warning) error(ea_warning);
@@ -433,7 +433,7 @@ static void ApplyPatchMulti(gpointer data, gpointer user_data)
433433
char * outromext=GetExtension(outromname);
434434
strcpy(outromext, state->romext);
435435

436-
struct errorinfo errinf=ApplyPatchMem2(patch, state->rommem, state->removeHeaders, true, outromname, NULL);
436+
struct errorinfo errinf=ApplyPatchMem2(patch, state->rommem, state->removeHeaders, !cfg.getint("skipchecksum"), outromname, NULL);
437437
if (errinf.level==el_broken) error(e_invalid);
438438
if (errinf.level==el_notthis) error(e_invalid_this);
439439
if (errinf.level==el_warning) error(e_warning);
@@ -486,7 +486,7 @@ static void a_ApplyPatch(GtkButton* widget, gpointer user_data)
486486
char * outromname=SelectRom(outromname_d, "Select Output File", true);
487487
if (outromname)
488488
{
489-
struct errorinfo errinf=ApplyPatchMem(patchfile, inromname, true, outromname, NULL, cfg.getint("autorom"));
489+
struct errorinfo errinf=ApplyPatchMem(patchfile, inromname, !cfg.getint("skipchecksum"), outromname, NULL, cfg.getint("autorom"));
490490
ShowMessage(errinf);
491491
}
492492
g_free(inromname);
@@ -677,7 +677,7 @@ static void a_ApplyRun(GtkButton* widget, gpointer user_data)
677677
else outromname=g_file_get_uri(outrom_file);
678678
g_object_unref(outrom_file);
679679

680-
struct errorinfo errinf=ApplyPatchMem(patchfile, romname, true, outromname, NULL, cfg.getint("autorom"));
680+
struct errorinfo errinf=ApplyPatchMem(patchfile, romname, !cfg.getint("skipchecksum"), outromname, NULL, cfg.getint("autorom"));
681681
if (errinf.level!=el_ok) ShowMessage(errinf);
682682
if (errinf.level>=el_notthis) goto cleanup;
683683

@@ -763,15 +763,24 @@ static void a_ShowSettings(GtkButton* widget, gpointer user_data)
763763
gtk_grid_attach(grid, autoRom, 0,3, 1,1);
764764
flatpakDisable(autoRom);
765765

766+
GtkWidget* skipChecksum;
767+
skipChecksum=gtk_check_button_new_with_mnemonic("Ignore checksum when patching");
768+
if (cfg.getint("skipchecksum")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(skipChecksum), true);
769+
g_object_ref(skipChecksum);
770+
gtk_grid_attach(grid, skipChecksum, 0,4, 1,1);
771+
flatpakDisable(skipChecksum);
772+
766773
gtk_container_add(GTK_CONTAINER(settingswindow), GTK_WIDGET(grid));
767774

768775
gtk_widget_show_all(settingswindow);
769776
gtk_main();
770777

771778
cfg.setint("assocemu", (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(emuAssoc))));
772779
cfg.setint("autorom", (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(autoRom))));
780+
cfg.setint("skipchecksum", (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(skipChecksum))));
773781
g_object_unref(emuAssoc);
774782
g_object_unref(autoRom);
783+
g_object_unref(skipChecksum);
775784
}
776785

777786
static gboolean filterExecOnly(const GtkFileFilterInfo* filter_info, gpointer data)

flips-w32.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct {
9090
unsigned char lastRomType;
9191
bool openInEmulatorOnAssoc;
9292
bool enableAutoRomSelector;
93+
bool skipChecksum;
9394
enum patchtype lastPatchType;
9495
int windowleft;
9596
int windowtop;
@@ -264,7 +265,7 @@ int a_ApplyPatch(LPCWSTR clipatchname)
264265
if (*inromext && *outromext) wcscpy(outromext, inromext);
265266
}
266267
if (!SelectRom(outromname, TEXT("Select Output File"), true)) goto cancel;
267-
struct errorinfo errinf=ApplyPatchMem(patch, inromname, true, outromname, NULL, state.enableAutoRomSelector);
268+
struct errorinfo errinf=ApplyPatchMem(patch, inromname, !state.skipChecksum, outromname, NULL, state.enableAutoRomSelector);
268269
delete patch;
269270
MessageBoxA(hwndMain, errinf.description, flipsversion, mboxtype[errinf.level]);
270271
return errinf.level;
@@ -334,7 +335,7 @@ int a_ApplyPatch(LPCWSTR clipatchname)
334335
if (foundRom!=romname) canUseFoundRom=false;
335336

336337
wcscpy(GetExtension(thisFileName), GetExtension(romname));
337-
struct errorinfo errinf=ApplyPatchMem(patch, romname, true, thisFileNameWithPath, NULL, true);
338+
struct errorinfo errinf=ApplyPatchMem(patch, romname, !state.skipChecksum, thisFileNameWithPath, NULL, true);
338339

339340
if (errinf.level==el_broken) worsterror=max(worsterror, e_invalid);
340341
if (errinf.level==el_notthis) worsterror=max(worsterror, e_no_auto);
@@ -410,7 +411,7 @@ int a_ApplyPatch(LPCWSTR clipatchname)
410411
{
411412
LPWSTR patchExtension=GetExtension(thisFileName);
412413
wcscpy(patchExtension, romExtension);
413-
struct errorinfo errinf=ApplyPatchMem2(patch, inrom, removeheaders, true, thisFileNameWithPath, NULL);
414+
struct errorinfo errinf=ApplyPatchMem2(patch, inrom, removeheaders, !state.skipChecksum, thisFileNameWithPath, NULL);
414415

415416
if (errinf.level==el_broken) worsterror=max(worsterror, e_invalid);
416417
if (errinf.level==el_notthis) worsterror=max(worsterror, e_invalid_this);
@@ -566,7 +567,7 @@ int a_ApplyRun(LPCWSTR clipatchname)
566567
WCHAR outfilename[MAX_PATH];
567568
GetFullPathName(outfilename_rel, MAX_PATH, outfilename, NULL);
568569

569-
errinf=ApplyPatchMem(patch, romname, true, outfilename, NULL, state.enableAutoRomSelector);
570+
errinf=ApplyPatchMem(patch, romname, !state.skipChecksum, outfilename, NULL, state.enableAutoRomSelector);
570571
error:
571572

572573
if (errinf.level!=el_ok) MessageBoxA(hwndMain, errinf.description, flipsversion, mboxtype[errinf.level]);
@@ -616,7 +617,7 @@ void a_ShowSettings()
616617
hwndSettings=CreateWindowA(
617618
"floatingmunchers", flipsversion,
618619
WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_BORDER|WS_MINIMIZEBOX,
619-
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);
620+
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);
620621

621622
HFONT hfont=(HFONT)GetStockObject(DEFAULT_GUI_FONT);
622623
HWND item;
@@ -674,6 +675,10 @@ void a_ShowSettings()
674675
check("Enable automatic ROM selector", 202, 17, 105); Button_SetCheck(item, (state.enableAutoRomSelector));
675676
endline(3);
676677

678+
line(17);
679+
check("Ignore checksum when patching", 202, 17, 106); Button_SetCheck(item, (state.skipChecksum));
680+
endline(3);
681+
677682
ShowWindow(hwndSettings, SW_SHOW);
678683
#undef firstbutton
679684
#undef button
@@ -782,6 +787,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
782787
if (wParam==103) state.openInEmulatorOnAssoc=false;
783788
if (wParam==104) state.openInEmulatorOnAssoc=true;
784789
if (wParam==105) state.enableAutoRomSelector^=1;
790+
if (wParam==106) state.skipChecksum^=1;
785791
}
786792
break;
787793
case WM_CLOSE:
@@ -934,6 +940,7 @@ void GUILoadConfig()
934940
state.lastRomType=0;
935941
state.openInEmulatorOnAssoc=false;
936942
state.enableAutoRomSelector=false;
943+
state.skipChecksum=false;
937944
state.lastPatchType=ty_bps;
938945
state.windowleft=CW_USEDEFAULT;
939946
state.windowtop=CW_USEDEFAULT;

0 commit comments

Comments
 (0)