Added a Checksum recalculation option when saving ROM images that have a bad Checksum

(re: Diesel ROMs seem to have an invalid fifth Checksum)

git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@361 38686702-15cf-42e4-a595-3071df8bf5ea
This commit is contained in:
Dale Schultz 2011-10-13 03:13:26 +00:00
parent 455fa71d6f
commit 1b6bf5f02f
9 changed files with 72 additions and 19 deletions

View File

@ -82,11 +82,13 @@ This is the first beta release of the upcoming official 0.5.4b release.
- Added a Logger startup Progress Bar as loading plugins sometimes takes time.
- Added colour to "Log to File" button. Red when recording and green when not.
- Added colour to "Un-select ALL" button. Yellow so it stands out.
* Button colours may not appear complete as this is platform dependent to implement.
* Button colours may not appear correctly as this is platform dependent.
- Changed "Log to File" keyboard shortcut from F1 to Spacebar.
--- Editor ---
- Set JInternalFrame.isPalette in TableFarme.java so table titles are visible on
Mac OS.
- Added a Checksum recalculation option when saving ROM images that have a bad Checksum
(re: Diesel ROMs seem to have an invalid fifth Checksum)
0.5.3b RC10 (09/12/2011)

View File

@ -19,15 +19,13 @@
package com.romraider.maps;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.logger.ecu.ui.handler.table.TableUpdateHandler;
import com.romraider.swing.JProgressPane;
import com.romraider.xml.TableNotFoundException;
import static com.romraider.maps.RomChecksum.calculateRomChecksum;
import static com.romraider.util.HexUtil.asBytes;
import static com.romraider.util.HexUtil.asHex;
import org.apache.log4j.Logger;
import javax.swing.JOptionPane;
import static javax.swing.JOptionPane.DEFAULT_OPTION;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
import static javax.swing.JOptionPane.showOptionDialog;
import java.io.File;
import java.io.Serializable;
import java.text.SimpleDateFormat;
@ -36,6 +34,15 @@ import java.util.Date;
import java.util.List;
import java.util.Vector;
import javax.swing.JOptionPane;
import org.apache.log4j.Logger;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.logger.ecu.ui.handler.table.TableUpdateHandler;
import com.romraider.swing.JProgressPane;
import com.romraider.xml.TableNotFoundException;
public class Rom implements Serializable {
private static final long serialVersionUID = 7865405179738828128L;
private static final Logger LOGGER = Logger.getLogger(Rom.class);
@ -212,6 +219,23 @@ public class Rom implements Serializable {
if (checksum != null && !checksum.isLocked()) {
calculateRomChecksum(binData, checksum.getStorageAddress(), checksum.getDataSize());
}
else if (checksum != null && checksum.isLocked() && !checksum.isButtonSelected()) {
Object[] options = {"Yes", "No"};
String message = String.format("One or more ROM image Checksums is invalid. " +
"Calculate new Checksums?%n" +
"(NOTE: this will only fix the Checksums it will NOT repair a corrupt ROM image)");
int answer = showOptionDialog(container,
message,
"Checksum Fix",
DEFAULT_OPTION,
QUESTION_MESSAGE,
null,
options,
options[0]);
if (answer == 0) {
calculateRomChecksum(binData, checksum.getStorageAddress(), checksum.getDataSize());
}
}
if (checksum != null) {
byte count = binData[checksum.getStorageAddress() + 207];
if (count == -1) {

View File

@ -55,7 +55,7 @@ public class RomChecksum {
}
for (j = 0; j < (dataSize / 12); j++) {
if (results[j] != 0) {
return result = 1; // 1, a checksum is invalid
return j + 1; // position of invalid checksum
}
}
return result; // 0, all checksums are valid

View File

@ -1239,6 +1239,8 @@ public abstract class Table extends JPanel implements Serializable {
public abstract boolean isLiveDataSupported();
public abstract boolean isButtonSelected();
protected void highlightLiveData() {
}

View File

@ -181,4 +181,8 @@ public class Table1D extends Table {
public boolean isLiveDataSupported() {
return false;
}
public boolean isButtonSelected() {
return true;
}
}

View File

@ -305,7 +305,11 @@ public class Table2D extends Table {
return !isNullOrEmpty(axis.getLogParam());
}
protected void highlightLiveData() {
public boolean isButtonSelected() {
return true;
}
protected void highlightLiveData() {
if (overlayLog && frame.isVisible()) {
AxisRange range = getLiveDataRangeForAxis(axis);
clearSelection();

View File

@ -916,7 +916,11 @@ public class Table3D extends Table {
return !isNullOrEmpty(xAxis.getLogParam()) && !isNullOrEmpty(yAxis.getLogParam());
}
protected void highlightLiveData() {
public boolean isButtonSelected() {
return true;
}
protected void highlightLiveData() {
if (overlayLog && frame.isVisible()) {
AxisRange rangeX = getLiveDataRangeForAxis(xAxis);
AxisRange rangeY = getLiveDataRangeForAxis(yAxis);

View File

@ -19,7 +19,11 @@
package com.romraider.maps;
import static com.romraider.maps.RomChecksum.validateRomChecksum;
import static com.romraider.util.ByteUtil.indexOfBytes;
import static com.romraider.util.HexUtil.asBytes;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.showMessageDialog;
@ -40,9 +44,6 @@ import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import com.romraider.Settings;
import static com.romraider.util.ByteUtil.indexOfBytes;
import static com.romraider.util.HexUtil.asBytes;
import static com.romraider.maps.RomChecksum.validateRomChecksum;
public class TableSwitch extends Table {
@ -79,17 +80,20 @@ public class TableSwitch extends Table {
add(radioPanel, BorderLayout.CENTER);
// Validate the ROM image checksums.
// if the result is 1: any checksum failed
// if the result is >0: position of failed checksum
// if the result is 0: all the checksums matched
// if the result is -1: all the checksums have been previously disabled
if (super.getName().equalsIgnoreCase("Checksum Fix")) {
int result = validateRomChecksum(input, storageAddress, dataSize);
String message = String.format("One or more Checksums is invalid.%nThe ROM image may be corrupt.%nUse of this ROM image is not advised!");
if (result == 1) {
String message = String.format(
"Checksum No. %d is invalid.%n" +
"The ROM image may be corrupt.%n" +
"Use of this ROM image is not advised!", result);
if (result > 0) {
showMessageDialog(this,
message,
"ERROR - Checksums Failed",
ERROR_MESSAGE);
WARNING_MESSAGE);
setButtonsUnselected(buttonGroup);
}
else if (result == -1){
@ -97,7 +101,7 @@ public class TableSwitch extends Table {
showMessageDialog(this,
message,
"Warning - Checksum Status",
WARNING_MESSAGE);
INFORMATION_MESSAGE);
getButtonByText(buttonGroup, "on").setSelected(true); }
else {
getButtonByText(buttonGroup, "off").setSelected(true);
@ -224,6 +228,15 @@ public class TableSwitch extends Table {
return false;
}
public boolean isButtonSelected() {
if (buttonGroup.getSelection() == null) {
return false;
}
else {
return true;
}
}
// returns the selected radio button in the specified group
private static JRadioButton getSelectedButton(ButtonGroup group) {
for (Enumeration<AbstractButton> e = group.getElements(); e.hasMoreElements(); ) {

View File

@ -23,7 +23,7 @@ version.minor=5
version.patch=4
version.buildnumber=${buildnumber}
version.extra=Beta
version.extra1=pre-RC1
version.extra1=RC1
# the starting class for the application
class.start=com.romraider.ECUExec