From 9a7a02fe636a3f74c5d9c79e297b79ea709dae8a Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Mon, 1 Dec 2008 20:55:45 +0000 Subject: [PATCH] bugfixes for patches and isoproperties (and starting on edit/add patches) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1370 8ced0084-cf51-0410-be5f-012b33b47a6e --- Data/User/GameConfig/GALP01.ini | 2 +- Data/User/GameConfig/GZLE01.ini | 18 ++--- Data/User/GameConfig/GZLP01.ini | 16 ++-- Source/Core/Core/Src/PatchEngine.cpp | 4 + Source/Core/DolphinWX/Src/ISOProperties.cpp | 88 +++++++++++++++++++-- Source/Core/DolphinWX/Src/ISOProperties.h | 14 ++++ 6 files changed, 118 insertions(+), 24 deletions(-) diff --git a/Data/User/GameConfig/GALP01.ini b/Data/User/GameConfig/GALP01.ini index 5d9973c58e..502f92b6ee 100644 --- a/Data/User/GameConfig/GALP01.ini +++ b/Data/User/GameConfig/GALP01.ini @@ -6,7 +6,7 @@ EmulationStateId = 4 [OnFrame] #Add memory patches to be applied every frame here. -0x8044CD30=dword:0xFFFFFFFF +0x8044CD30:dword:0xFFFFFFFF [ActionReplay] #Add action replay cheats here. $P1 - No Damage diff --git a/Data/User/GameConfig/GZLE01.ini b/Data/User/GameConfig/GZLE01.ini index 677704cc1b..1469b285a0 100644 --- a/Data/User/GameConfig/GZLE01.ini +++ b/Data/User/GameConfig/GZLE01.ini @@ -7,19 +7,19 @@ EmulationStateId = 2 [OnFrame] #Add memory patches to be applied every frame here. +$Fix item hang -0x802904b4=dword:0x4E800020 +0x802904b4:dword:0x4E800020 $Max health -0x803C4C09=byte:0x50 +0x803C4C09:byte:0x50 $Current health -0x803C4C0B=byte:0x50 +0x803C4C0B:byte:0x50 $Hidden dungeon -0x803C9D44=dword:0x000000FF -0x803C9D48=dword:0x485F7465 -0x803C9D4C=dword:0x73740000 +0x803C9D44:dword:0x000000FF +0x803C9D48:dword:0x485F7465 +0x803C9D4C:dword:0x73740000 $Snow test room -0x803C9D44=dword:0x000000FF -0x803C9D48=dword:0x49546573 -0x803C9D4C=dword:0x74363200 +0x803C9D44:dword:0x000000FF +0x803C9D48:dword:0x49546573 +0x803C9D4C:dword:0x74363200 [ActionReplay] #Add action replay cheats here. #Codes by GCNHacker87 diff --git a/Data/User/GameConfig/GZLP01.ini b/Data/User/GameConfig/GZLP01.ini index a14ef6eff1..5dd8c0670a 100644 --- a/Data/User/GameConfig/GZLP01.ini +++ b/Data/User/GameConfig/GZLP01.ini @@ -9,17 +9,17 @@ EmulationStateId = 2 +$Fix item hang 0x80295654:dword:0x4E800020 $Max health -0x803C4C09=byte:0x50 +0x803C4C09:byte:0x50 $Current health -0x803C4C0B=byte:0x50 +0x803C4C0B:byte:0x50 $Hidden dungeon -0x803C9D44=dword:0x000000FF -0x803C9D48=dword:0x485F7465 -0x803C9D4C=dword:0x73740000 +0x803C9D44:dword:0x000000FF +0x803C9D48:dword:0x485F7465 +0x803C9D4C:dword:0x73740000 $Snow test room -0x803C9D44=dword:0x000000FF -0x803C9D48=dword:0x49546573 -0x803C9D4C=dword:0x74363200 +0x803C9D44:dword:0x000000FF +0x803C9D48:dword:0x49546573 +0x803C9D4C:dword:0x74363200 [ActionReplay] #Add action replay cheats here. $(M) diff --git a/Source/Core/Core/Src/PatchEngine.cpp b/Source/Core/Core/Src/PatchEngine.cpp index c436f42a33..9f2b691c45 100644 --- a/Source/Core/Core/Src/PatchEngine.cpp +++ b/Source/Core/Core/Src/PatchEngine.cpp @@ -70,6 +70,10 @@ void LoadPatchSection(const char *section, std::vector &patches, IniFile continue; } + std::string::size_type loc = line.find_first_of('=', 0); + if (loc != std::string::npos) + line.at(loc) = ':'; + std::vector items; SplitString(line, ":", items); if (items.size() >= 3) { diff --git a/Source/Core/DolphinWX/Src/ISOProperties.cpp b/Source/Core/DolphinWX/Src/ISOProperties.cpp index 2071e441bc..6275dc3008 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.cpp +++ b/Source/Core/DolphinWX/Src/ISOProperties.cpp @@ -598,12 +598,18 @@ void CISOProperties::ListSelectionChanged(wxCommandEvent& event) switch (event.GetId()) { case ID_PATCHES_LIST: - EditPatch->Enable(); - RemovePatch->Enable(); + if (Patches->GetSelection() != wxNOT_FOUND) + { + EditPatch->Enable(); + RemovePatch->Enable(); + } break; case ID_CHEATS_LIST: - EditCheat->Enable(); - RemoveCheat->Enable(); + if (Cheats->GetSelection() != wxNOT_FOUND) + { + EditCheat->Enable(); + RemoveCheat->Enable(); + } break; } } @@ -611,6 +617,7 @@ void CISOProperties::ListSelectionChanged(wxCommandEvent& event) void CISOProperties::PatchList_Load() { onFrame.clear(); + Patches->Clear(); PatchEngine::LoadPatchSection("OnFrame", onFrame, GameIni); u32 index = 0; @@ -643,15 +650,83 @@ void CISOProperties::PatchList_Save() lines.clear(); } + +void CISOProperties::ChangeEditPatchEntry(wxSpinEvent& event) +{ + PatchEngine::PatchEntry pE = onFrame.at(Patches->GetSelection()).entries.at(event.GetPosition()); + EditPatchOffset->SetValue(wxString::Format("%08X", pE.address)); + EditPatchType->SetSelection(pE.type); + EditPatchValue->SetValue(wxString::Format("%08X", pE.value)); +} + void CISOProperties::PatchButtonClicked(wxCommandEvent& event) { switch (event.GetId()) { case ID_EDITPATCH: - // dialog + { + int selection = Patches->GetSelection(); + std::string currentName = onFrame.at(selection).name; + std::vector currentEntries = onFrame.at(selection).entries; + wxDialog* dEditPatch = new wxDialog(this, IDD_EDITPATCH, wxString::Format("Edit Patch: %s", currentName.c_str()), wxDefaultPosition, wxSize(300, -1)); + + wxBoxSizer* sEditPatch = new wxBoxSizer(wxVERTICAL); + wxStaticText* EditPatchNameText = new wxStaticText(dEditPatch, ID_EDITPATCH_NAME_TEXT, _("Name:"), wxDefaultPosition, wxDefaultSize); + EditPatchName = new wxTextCtrl(dEditPatch, ID_EDITPATCH_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); + EditPatchName->SetValue(wxString::FromAscii(currentName.c_str())); + wxStaticText* EditPatchOffsetText = new wxStaticText(dEditPatch, ID_EDITPATCH_OFFSET_TEXT, _("Offset:"), wxDefaultPosition, wxDefaultSize); + EditPatchOffset = new wxTextCtrl(dEditPatch, ID_EDITPATCH_OFFSET, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); + EditPatchOffset->SetValue(wxString::Format("%08X", currentEntries.at(0).address)); + wxSpinButton* EntrySelection = new wxSpinButton(dEditPatch, ID_ENTRY_SELECT, wxDefaultPosition, wxDefaultSize, wxVERTICAL); + EntrySelection->SetRange(0, currentEntries.size()); + wxArrayString wxArrayStringFor_EditPatchType; + for (int i = 0; i < 3; ++i) + wxArrayStringFor_EditPatchType.Add(wxString::FromAscii(PatchEngine::PatchTypeStrings[i])); + EditPatchType = new wxRadioBox(dEditPatch, ID_EDITPATCH_TYPE, _("Type"), wxDefaultPosition, wxDefaultSize, wxArrayStringFor_EditPatchType, 3, wxRA_SPECIFY_COLS, wxDefaultValidator); + EditPatchType->SetSelection((int)currentEntries.at(0).type); + wxStaticText* EditPatchValueText = new wxStaticText(dEditPatch, ID_EDITPATCH_VALUE_TEXT, _("Value:"), wxDefaultPosition, wxDefaultSize); + EditPatchValue = new wxTextCtrl(dEditPatch, ID_EDITPATCH_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); + EditPatchValue->SetValue(wxString::Format("%08X", currentEntries.at(0).value)); + wxBoxSizer* sEditPatchName = new wxBoxSizer(wxHORIZONTAL); + sEditPatchName->Add(EditPatchNameText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + sEditPatchName->Add(EditPatchName, 1, wxEXPAND|wxALL, 5); + sEditPatch->Add(sEditPatchName, 0, wxEXPAND); + wxStaticBoxSizer* sbEntry = new wxStaticBoxSizer(wxVERTICAL, dEditPatch, _("Entry")); + wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0); + sgEntry->AddGrowableCol(1); + sgEntry->Add(EditPatchOffsetText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); + sgEntry->Add(EditPatchOffset, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); + sgEntry->Add(EntrySelection, wxGBPosition(0, 2), wxGBSpan(3, 1), wxEXPAND|wxALL, 5); + sgEntry->Add(EditPatchType, wxGBPosition(1, 0), wxGBSpan(1, 2), wxEXPAND|wxALL, 5); + sgEntry->Add(EditPatchValueText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); + sgEntry->Add(EditPatchValue, wxGBPosition(2, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5); + sbEntry->Add(sgEntry, 0, wxEXPAND); + sEditPatch->Add(sbEntry, 0, wxEXPAND|wxALL, 5); + wxBoxSizer* sEditPatchButtons = new wxBoxSizer(wxHORIZONTAL); + wxButton* bOK = new wxButton(dEditPatch, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + wxButton* bCancel = new wxButton(dEditPatch, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + sEditPatchButtons->Add(0, 0, 1, wxEXPAND, 5); + sEditPatchButtons->Add(bOK, 0, wxALL, 5); + sEditPatchButtons->Add(bCancel, 0, wxALL, 5); + sEditPatch->Add(sEditPatchButtons, 0, wxEXPAND, 5); + dEditPatch->SetSizer(sEditPatch); + sEditPatch->Layout(); + if (dEditPatch->ShowModal() == wxID_OK) + { + onFrame.at(selection).name = std::string(EditPatchName->GetValue().mb_str()); + unsigned long value; + if (EditPatchOffset->GetValue().ToULong(&value, 16)) + onFrame.at(selection).entries.at(0).address = value; + onFrame.at(selection).entries.at(0).type = (PatchEngine::PatchType)EditPatchType->GetSelection(); + if (EditPatchValue->GetValue().ToULong(&value, 16)) + onFrame.at(selection).entries.at(0).value = value; + } + } break; case ID_ADDPATCH: - // dialog + { + // dialog; + } break; case ID_REMOVEPATCH: onFrame.erase(onFrame.begin() + Patches->GetSelection()); @@ -669,6 +744,7 @@ void CISOProperties::PatchButtonClicked(wxCommandEvent& event) void CISOProperties::ActionReplayList_Load() { ARCodes.clear(); + Cheats->Clear(); std::vector lines; if (!GameIni.GetLines("ActionReplay", lines)) diff --git a/Source/Core/DolphinWX/Src/ISOProperties.h b/Source/Core/DolphinWX/Src/ISOProperties.h index 418b487730..1bbf5a8c4b 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.h +++ b/Source/Core/DolphinWX/Src/ISOProperties.h @@ -86,6 +86,10 @@ class CISOProperties : public wxDialog wxArrayString arrayStringFor_Patches; wxCheckListBox *Patches; wxButton *EditPatch; + wxTextCtrl *EditPatchName; + wxTextCtrl *EditPatchOffset; + wxRadioBox *EditPatchType; + wxTextCtrl *EditPatchValue; wxButton *AddPatch; wxButton *RemovePatch; wxArrayString arrayStringFor_Cheats; @@ -155,6 +159,15 @@ class CISOProperties : public wxDialog ID_EMUSTATE, ID_PATCHES_LIST, ID_EDITPATCH, + IDD_EDITPATCH, + ID_EDITPATCH_NAME_TEXT, + ID_EDITPATCH_NAME, + ID_EDITPATCH_OFFSET_TEXT, + ID_EDITPATCH_OFFSET, + ID_ENTRY_SELECT, + ID_EDITPATCH_TYPE, + ID_EDITPATCH_VALUE_TEXT, + ID_EDITPATCH_VALUE, ID_ADDPATCH, ID_REMOVEPATCH, ID_CHEATS_LIST, @@ -200,6 +213,7 @@ class CISOProperties : public wxDialog void OnEditConfig(wxCommandEvent& event); void ListSelectionChanged(wxCommandEvent& event); void PatchButtonClicked(wxCommandEvent& event); + void ChangeEditPatchEntry(wxSpinEvent& event); void ActionReplayButtonClicked(wxCommandEvent& event); void RightClickOnBanner(wxMouseEvent& event); void OnBannerImageSave(wxCommandEvent& event);