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
This commit is contained in:
Shawn Hoffman 2008-12-01 20:55:45 +00:00
parent 751124bb68
commit 9a7a02fe63
6 changed files with 118 additions and 24 deletions

View File

@ -6,7 +6,7 @@
EmulationStateId = 4 EmulationStateId = 4
[OnFrame] [OnFrame]
#Add memory patches to be applied every frame here. #Add memory patches to be applied every frame here.
0x8044CD30=dword:0xFFFFFFFF 0x8044CD30:dword:0xFFFFFFFF
[ActionReplay] [ActionReplay]
#Add action replay cheats here. #Add action replay cheats here.
$P1 - No Damage $P1 - No Damage

View File

@ -7,19 +7,19 @@ EmulationStateId = 2
[OnFrame] [OnFrame]
#Add memory patches to be applied every frame here. #Add memory patches to be applied every frame here.
+$Fix item hang +$Fix item hang
0x802904b4=dword:0x4E800020 0x802904b4:dword:0x4E800020
$Max health $Max health
0x803C4C09=byte:0x50 0x803C4C09:byte:0x50
$Current health $Current health
0x803C4C0B=byte:0x50 0x803C4C0B:byte:0x50
$Hidden dungeon $Hidden dungeon
0x803C9D44=dword:0x000000FF 0x803C9D44:dword:0x000000FF
0x803C9D48=dword:0x485F7465 0x803C9D48:dword:0x485F7465
0x803C9D4C=dword:0x73740000 0x803C9D4C:dword:0x73740000
$Snow test room $Snow test room
0x803C9D44=dword:0x000000FF 0x803C9D44:dword:0x000000FF
0x803C9D48=dword:0x49546573 0x803C9D48:dword:0x49546573
0x803C9D4C=dword:0x74363200 0x803C9D4C:dword:0x74363200
[ActionReplay] [ActionReplay]
#Add action replay cheats here. #Add action replay cheats here.
#Codes by GCNHacker87 #Codes by GCNHacker87

View File

@ -9,17 +9,17 @@ EmulationStateId = 2
+$Fix item hang +$Fix item hang
0x80295654:dword:0x4E800020 0x80295654:dword:0x4E800020
$Max health $Max health
0x803C4C09=byte:0x50 0x803C4C09:byte:0x50
$Current health $Current health
0x803C4C0B=byte:0x50 0x803C4C0B:byte:0x50
$Hidden dungeon $Hidden dungeon
0x803C9D44=dword:0x000000FF 0x803C9D44:dword:0x000000FF
0x803C9D48=dword:0x485F7465 0x803C9D48:dword:0x485F7465
0x803C9D4C=dword:0x73740000 0x803C9D4C:dword:0x73740000
$Snow test room $Snow test room
0x803C9D44=dword:0x000000FF 0x803C9D44:dword:0x000000FF
0x803C9D48=dword:0x49546573 0x803C9D48:dword:0x49546573
0x803C9D4C=dword:0x74363200 0x803C9D4C:dword:0x74363200
[ActionReplay] [ActionReplay]
#Add action replay cheats here. #Add action replay cheats here.
$(M) $(M)

View File

@ -70,6 +70,10 @@ void LoadPatchSection(const char *section, std::vector<Patch> &patches, IniFile
continue; continue;
} }
std::string::size_type loc = line.find_first_of('=', 0);
if (loc != std::string::npos)
line.at(loc) = ':';
std::vector<std::string> items; std::vector<std::string> items;
SplitString(line, ":", items); SplitString(line, ":", items);
if (items.size() >= 3) { if (items.size() >= 3) {

View File

@ -598,12 +598,18 @@ void CISOProperties::ListSelectionChanged(wxCommandEvent& event)
switch (event.GetId()) switch (event.GetId())
{ {
case ID_PATCHES_LIST: case ID_PATCHES_LIST:
EditPatch->Enable(); if (Patches->GetSelection() != wxNOT_FOUND)
RemovePatch->Enable(); {
EditPatch->Enable();
RemovePatch->Enable();
}
break; break;
case ID_CHEATS_LIST: case ID_CHEATS_LIST:
EditCheat->Enable(); if (Cheats->GetSelection() != wxNOT_FOUND)
RemoveCheat->Enable(); {
EditCheat->Enable();
RemoveCheat->Enable();
}
break; break;
} }
} }
@ -611,6 +617,7 @@ void CISOProperties::ListSelectionChanged(wxCommandEvent& event)
void CISOProperties::PatchList_Load() void CISOProperties::PatchList_Load()
{ {
onFrame.clear(); onFrame.clear();
Patches->Clear();
PatchEngine::LoadPatchSection("OnFrame", onFrame, GameIni); PatchEngine::LoadPatchSection("OnFrame", onFrame, GameIni);
u32 index = 0; u32 index = 0;
@ -643,15 +650,83 @@ void CISOProperties::PatchList_Save()
lines.clear(); 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) void CISOProperties::PatchButtonClicked(wxCommandEvent& event)
{ {
switch (event.GetId()) switch (event.GetId())
{ {
case ID_EDITPATCH: case ID_EDITPATCH:
// dialog {
int selection = Patches->GetSelection();
std::string currentName = onFrame.at(selection).name;
std::vector<PatchEngine::PatchEntry> 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; break;
case ID_ADDPATCH: case ID_ADDPATCH:
// dialog {
// dialog;
}
break; break;
case ID_REMOVEPATCH: case ID_REMOVEPATCH:
onFrame.erase(onFrame.begin() + Patches->GetSelection()); onFrame.erase(onFrame.begin() + Patches->GetSelection());
@ -669,6 +744,7 @@ void CISOProperties::PatchButtonClicked(wxCommandEvent& event)
void CISOProperties::ActionReplayList_Load() void CISOProperties::ActionReplayList_Load()
{ {
ARCodes.clear(); ARCodes.clear();
Cheats->Clear();
std::vector<std::string> lines; std::vector<std::string> lines;
if (!GameIni.GetLines("ActionReplay", lines)) if (!GameIni.GetLines("ActionReplay", lines))

View File

@ -86,6 +86,10 @@ class CISOProperties : public wxDialog
wxArrayString arrayStringFor_Patches; wxArrayString arrayStringFor_Patches;
wxCheckListBox *Patches; wxCheckListBox *Patches;
wxButton *EditPatch; wxButton *EditPatch;
wxTextCtrl *EditPatchName;
wxTextCtrl *EditPatchOffset;
wxRadioBox *EditPatchType;
wxTextCtrl *EditPatchValue;
wxButton *AddPatch; wxButton *AddPatch;
wxButton *RemovePatch; wxButton *RemovePatch;
wxArrayString arrayStringFor_Cheats; wxArrayString arrayStringFor_Cheats;
@ -155,6 +159,15 @@ class CISOProperties : public wxDialog
ID_EMUSTATE, ID_EMUSTATE,
ID_PATCHES_LIST, ID_PATCHES_LIST,
ID_EDITPATCH, 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_ADDPATCH,
ID_REMOVEPATCH, ID_REMOVEPATCH,
ID_CHEATS_LIST, ID_CHEATS_LIST,
@ -200,6 +213,7 @@ class CISOProperties : public wxDialog
void OnEditConfig(wxCommandEvent& event); void OnEditConfig(wxCommandEvent& event);
void ListSelectionChanged(wxCommandEvent& event); void ListSelectionChanged(wxCommandEvent& event);
void PatchButtonClicked(wxCommandEvent& event); void PatchButtonClicked(wxCommandEvent& event);
void ChangeEditPatchEntry(wxSpinEvent& event);
void ActionReplayButtonClicked(wxCommandEvent& event); void ActionReplayButtonClicked(wxCommandEvent& event);
void RightClickOnBanner(wxMouseEvent& event); void RightClickOnBanner(wxMouseEvent& event);
void OnBannerImageSave(wxCommandEvent& event); void OnBannerImageSave(wxCommandEvent& event);