mirror of https://github.com/rusefi/RomRaider.git
Added support for sign integer data (used in diesel ROMs)
git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@304 38686702-15cf-42e4-a595-3071df8bf5ea
This commit is contained in:
parent
30ba5f9c93
commit
907596a518
|
@ -56,7 +56,7 @@ This is the seventh beta release of the upcoming official 0.5.3b release.
|
||||||
- Change Log -
|
- Change Log -
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
0.5.3b RC7 (11/20/2010)
|
0.5.3b RC7 (12/11/2010)
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
--- Logger ---
|
--- Logger ---
|
||||||
|
@ -66,6 +66,7 @@ This is the seventh beta release of the upcoming official 0.5.3b release.
|
||||||
- Added saving parameter list show/hide to settings
|
- Added saving parameter list show/hide to settings
|
||||||
- Added USER input read ability for ZT2
|
- Added USER input read ability for ZT2
|
||||||
- Added check box to enable/disable COM port refreshing and save the setting
|
- Added check box to enable/disable COM port refreshing and save the setting
|
||||||
|
- Added support for sign integer data (used in diesel ROMs)
|
||||||
|
|
||||||
0.5.3b RC6 (05/02/2009)
|
0.5.3b RC6 (05/02/2009)
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
|
@ -20,10 +20,84 @@
|
||||||
package com.romraider.logger.ecu;
|
package com.romraider.logger.ecu;
|
||||||
|
|
||||||
import static com.centerkey.utils.BareBonesBrowserLaunch.openURL;
|
import static com.centerkey.utils.BareBonesBrowserLaunch.openURL;
|
||||||
import com.romraider.Settings;
|
|
||||||
import static com.romraider.Version.LOGGER_DEFS_URL;
|
import static com.romraider.Version.LOGGER_DEFS_URL;
|
||||||
import static com.romraider.Version.PRODUCT_NAME;
|
import static com.romraider.Version.PRODUCT_NAME;
|
||||||
import static com.romraider.Version.VERSION;
|
import static com.romraider.Version.VERSION;
|
||||||
|
import static com.romraider.logger.ecu.profile.UserProfileLoader.BACKUP_PATH;
|
||||||
|
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.saveProfileToFile;
|
||||||
|
import static com.romraider.logger.ecu.ui.swing.vertical.VerticalTextIcon.ROTATE_LEFT;
|
||||||
|
import static com.romraider.util.ParamChecker.checkNotNull;
|
||||||
|
import static com.romraider.util.ParamChecker.isNullOrEmpty;
|
||||||
|
import static com.romraider.util.ThreadUtil.runAsDaemon;
|
||||||
|
import static com.romraider.util.ThreadUtil.sleep;
|
||||||
|
import static java.awt.BorderLayout.CENTER;
|
||||||
|
import static java.awt.BorderLayout.EAST;
|
||||||
|
import static java.awt.BorderLayout.NORTH;
|
||||||
|
import static java.awt.BorderLayout.SOUTH;
|
||||||
|
import static java.awt.BorderLayout.WEST;
|
||||||
|
import static java.awt.Color.BLACK;
|
||||||
|
import static java.awt.Color.RED;
|
||||||
|
import static java.lang.System.currentTimeMillis;
|
||||||
|
import static java.util.Collections.sort;
|
||||||
|
import static javax.swing.BorderFactory.createLoweredBevelBorder;
|
||||||
|
import static javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW;
|
||||||
|
import static javax.swing.JOptionPane.DEFAULT_OPTION;
|
||||||
|
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
|
||||||
|
import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
||||||
|
import static javax.swing.JOptionPane.showMessageDialog;
|
||||||
|
import static javax.swing.JOptionPane.showOptionDialog;
|
||||||
|
import static javax.swing.JSplitPane.HORIZONTAL_SPLIT;
|
||||||
|
import static javax.swing.KeyStroke.getKeyStroke;
|
||||||
|
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
|
||||||
|
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
|
||||||
|
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
|
||||||
|
import static javax.swing.SwingConstants.BOTTOM;
|
||||||
|
import static javax.swing.SwingConstants.RIGHT;
|
||||||
|
import static javax.swing.SwingConstants.VERTICAL;
|
||||||
|
import static javax.swing.SwingUtilities.invokeLater;
|
||||||
|
|
||||||
|
import java.awt.AWTException;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Robot;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.beans.PropertyChangeEvent;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import javax.swing.AbstractAction;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
|
import javax.swing.JSplitPane;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
|
import javax.swing.table.TableColumn;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.romraider.Settings;
|
||||||
import com.romraider.editor.ecu.ECUEditor;
|
import com.romraider.editor.ecu.ECUEditor;
|
||||||
import com.romraider.io.serial.port.SerialPortRefresher;
|
import com.romraider.io.serial.port.SerialPortRefresher;
|
||||||
import com.romraider.logger.ecu.comms.controller.LoggerController;
|
import com.romraider.logger.ecu.comms.controller.LoggerController;
|
||||||
|
@ -46,7 +120,6 @@ import com.romraider.logger.ecu.profile.UserProfileImpl;
|
||||||
import com.romraider.logger.ecu.profile.UserProfileItem;
|
import com.romraider.logger.ecu.profile.UserProfileItem;
|
||||||
import com.romraider.logger.ecu.profile.UserProfileItemImpl;
|
import com.romraider.logger.ecu.profile.UserProfileItemImpl;
|
||||||
import com.romraider.logger.ecu.profile.UserProfileLoader;
|
import com.romraider.logger.ecu.profile.UserProfileLoader;
|
||||||
import static com.romraider.logger.ecu.profile.UserProfileLoader.BACKUP_PATH;
|
|
||||||
import com.romraider.logger.ecu.profile.UserProfileLoaderImpl;
|
import com.romraider.logger.ecu.profile.UserProfileLoaderImpl;
|
||||||
import com.romraider.logger.ecu.ui.DataRegistrationBroker;
|
import com.romraider.logger.ecu.ui.DataRegistrationBroker;
|
||||||
import com.romraider.logger.ecu.ui.DataRegistrationBrokerImpl;
|
import com.romraider.logger.ecu.ui.DataRegistrationBrokerImpl;
|
||||||
|
@ -74,9 +147,7 @@ import com.romraider.logger.ecu.ui.playback.PlaybackManagerImpl;
|
||||||
import com.romraider.logger.ecu.ui.swing.layout.BetterFlowLayout;
|
import com.romraider.logger.ecu.ui.swing.layout.BetterFlowLayout;
|
||||||
import com.romraider.logger.ecu.ui.swing.menubar.EcuLoggerMenuBar;
|
import com.romraider.logger.ecu.ui.swing.menubar.EcuLoggerMenuBar;
|
||||||
import com.romraider.logger.ecu.ui.swing.menubar.action.ToggleButtonAction;
|
import com.romraider.logger.ecu.ui.swing.menubar.action.ToggleButtonAction;
|
||||||
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.saveProfileToFile;
|
|
||||||
import com.romraider.logger.ecu.ui.swing.vertical.VerticalTextIcon;
|
import com.romraider.logger.ecu.ui.swing.vertical.VerticalTextIcon;
|
||||||
import static com.romraider.logger.ecu.ui.swing.vertical.VerticalTextIcon.ROTATE_LEFT;
|
|
||||||
import com.romraider.logger.ecu.ui.tab.dyno.DynoTab;
|
import com.romraider.logger.ecu.ui.tab.dyno.DynoTab;
|
||||||
import com.romraider.logger.ecu.ui.tab.dyno.DynoTabImpl;
|
import com.romraider.logger.ecu.ui.tab.dyno.DynoTabImpl;
|
||||||
import com.romraider.logger.ecu.ui.tab.injector.InjectorTab;
|
import com.romraider.logger.ecu.ui.tab.injector.InjectorTab;
|
||||||
|
@ -88,75 +159,8 @@ import com.romraider.logger.external.core.ExternalDataSource;
|
||||||
import com.romraider.logger.external.core.ExternalDataSourceLoader;
|
import com.romraider.logger.external.core.ExternalDataSourceLoader;
|
||||||
import com.romraider.logger.external.core.ExternalDataSourceLoaderImpl;
|
import com.romraider.logger.external.core.ExternalDataSourceLoaderImpl;
|
||||||
import com.romraider.swing.AbstractFrame;
|
import com.romraider.swing.AbstractFrame;
|
||||||
import static com.romraider.util.ParamChecker.checkNotNull;
|
|
||||||
import static com.romraider.util.ParamChecker.isNullOrEmpty;
|
|
||||||
import com.romraider.util.SettingsManagerImpl;
|
import com.romraider.util.SettingsManagerImpl;
|
||||||
import com.romraider.util.ThreadUtil;
|
import com.romraider.util.ThreadUtil;
|
||||||
import static com.romraider.util.ThreadUtil.runAsDaemon;
|
|
||||||
import static com.romraider.util.ThreadUtil.sleep;
|
|
||||||
import static java.awt.BorderLayout.CENTER;
|
|
||||||
import static java.awt.BorderLayout.EAST;
|
|
||||||
import static java.awt.BorderLayout.NORTH;
|
|
||||||
import static java.awt.BorderLayout.SOUTH;
|
|
||||||
import static java.awt.BorderLayout.WEST;
|
|
||||||
import static java.awt.Color.BLACK;
|
|
||||||
import static java.awt.Color.RED;
|
|
||||||
import static java.lang.System.currentTimeMillis;
|
|
||||||
import static java.util.Collections.sort;
|
|
||||||
import static javax.swing.BorderFactory.createLoweredBevelBorder;
|
|
||||||
import static javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW;
|
|
||||||
import static javax.swing.JLabel.RIGHT;
|
|
||||||
import static javax.swing.JOptionPane.DEFAULT_OPTION;
|
|
||||||
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
|
|
||||||
import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
|
||||||
import static javax.swing.JOptionPane.showMessageDialog;
|
|
||||||
import static javax.swing.JOptionPane.showOptionDialog;
|
|
||||||
import static javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED;
|
|
||||||
import static javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER;
|
|
||||||
import static javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
|
|
||||||
import static javax.swing.JSeparator.VERTICAL;
|
|
||||||
import static javax.swing.JSplitPane.HORIZONTAL_SPLIT;
|
|
||||||
import static javax.swing.JTabbedPane.BOTTOM;
|
|
||||||
import static javax.swing.KeyStroke.getKeyStroke;
|
|
||||||
import static javax.swing.SwingUtilities.invokeLater;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import javax.swing.AbstractAction;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JMenuBar;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.JSplitPane;
|
|
||||||
import javax.swing.JTabbedPane;
|
|
||||||
import javax.swing.JTable;
|
|
||||||
import javax.swing.JToggleButton;
|
|
||||||
import javax.swing.table.TableColumn;
|
|
||||||
import java.awt.AWTException;
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.FlowLayout;
|
|
||||||
import java.awt.GraphicsDevice;
|
|
||||||
import java.awt.GraphicsEnvironment;
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import java.awt.GridBagLayout;
|
|
||||||
import java.awt.Robot;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: add better debug logging, preferably to a file and switchable (on/off)
|
TODO: add better debug logging, preferably to a file and switchable (on/off)
|
||||||
|
|
|
@ -19,15 +19,11 @@
|
||||||
|
|
||||||
package com.romraider.maps;
|
package com.romraider.maps;
|
||||||
|
|
||||||
import com.romraider.util.JEPUtil;
|
|
||||||
import static java.awt.Color.BLACK;
|
import static java.awt.Color.BLACK;
|
||||||
import static java.awt.Color.BLUE;
|
import static java.awt.Color.BLUE;
|
||||||
import static java.awt.Color.RED;
|
import static java.awt.Color.RED;
|
||||||
import static java.lang.Math.abs;
|
import static java.lang.Math.abs;
|
||||||
import static javax.swing.BorderFactory.createLineBorder;
|
import static javax.swing.BorderFactory.createLineBorder;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.border.Border;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
@ -35,6 +31,10 @@ import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.border.Border;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import com.romraider.util.JEPUtil;
|
||||||
|
|
||||||
public class DataCell extends JLabel implements MouseListener, Serializable {
|
public class DataCell extends JLabel implements MouseListener, Serializable {
|
||||||
private static final long serialVersionUID = -2904293227148940937L;
|
private static final long serialVersionUID = -2904293227148940937L;
|
||||||
|
@ -126,15 +126,46 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
|
||||||
|
|
||||||
// make sure it's in range
|
// make sure it's in range
|
||||||
if (table.getStorageType() != Table.STORAGE_TYPE_FLOAT) {
|
if (table.getStorageType() != Table.STORAGE_TYPE_FLOAT) {
|
||||||
if (binValue < 0) {
|
if (table.isSignedData()) {
|
||||||
this.setBinValue(0);
|
int minAllowedValue = 0;
|
||||||
|
int maxAllowedValue = 0;
|
||||||
} else if (binValue > Math.pow(256, table.getStorageType()) - 1) {
|
// int typeStroageLimit = (int) (Math.pow(128, table.getStorageType()) * (Math.pow(2, table.getStorageType())/2));
|
||||||
this.setBinValue((int) (Math.pow(256, table.getStorageType()) - 1));
|
// if (binValue < typeStroageLimit *-1 ) {
|
||||||
|
// this.setBinValue(typeStroageLimit *-1);
|
||||||
}
|
// }
|
||||||
|
// else if (binValue > (typeStroageLimit - 1)) {
|
||||||
|
// this.setBinValue(typeStroageLimit - 1);
|
||||||
|
// }
|
||||||
|
switch (table.getStorageType()) {
|
||||||
|
case 1:
|
||||||
|
minAllowedValue = Byte.MIN_VALUE;
|
||||||
|
maxAllowedValue = Byte.MAX_VALUE;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
minAllowedValue = Short.MIN_VALUE;
|
||||||
|
maxAllowedValue = Short.MAX_VALUE;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
minAllowedValue = Integer.MIN_VALUE;
|
||||||
|
maxAllowedValue = Integer.MAX_VALUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (binValue < minAllowedValue ) {
|
||||||
|
this.setBinValue(minAllowedValue);
|
||||||
|
}
|
||||||
|
else if (binValue > maxAllowedValue) {
|
||||||
|
this.setBinValue(maxAllowedValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (binValue < 0) {
|
||||||
|
this.setBinValue(0);
|
||||||
|
}
|
||||||
|
else if (binValue > Math.pow(256, table.getStorageType()) - 1) {
|
||||||
|
this.setBinValue((int) (Math.pow(256, table.getStorageType()) - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateDisplayValue();
|
this.updateDisplayValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ public abstract class Table extends JPanel implements Serializable {
|
||||||
public static final int COMPARE_ABSOLUTE = 1;
|
public static final int COMPARE_ABSOLUTE = 1;
|
||||||
|
|
||||||
public static final int STORAGE_TYPE_FLOAT = 99;
|
public static final int STORAGE_TYPE_FLOAT = 99;
|
||||||
|
public static final boolean STORAGE_DATA_SIGNED = false;
|
||||||
|
|
||||||
protected static final Color UNCHANGED_VALUE_COLOR = new Color(160, 160, 160);
|
protected static final Color UNCHANGED_VALUE_COLOR = new Color(160, 160, 160);
|
||||||
|
|
||||||
|
@ -83,6 +84,7 @@ public abstract class Table extends JPanel implements Serializable {
|
||||||
|
|
||||||
protected int storageAddress;
|
protected int storageAddress;
|
||||||
protected int storageType;
|
protected int storageType;
|
||||||
|
protected boolean signed;
|
||||||
protected int endian;
|
protected int endian;
|
||||||
protected boolean flip;
|
protected boolean flip;
|
||||||
protected DataCell[] data = new DataCell[0];
|
protected DataCell[] data = new DataCell[0];
|
||||||
|
@ -411,7 +413,8 @@ public abstract class Table extends JPanel implements Serializable {
|
||||||
RomAttributeParser.parseByteValue(input,
|
RomAttributeParser.parseByteValue(input,
|
||||||
endian,
|
endian,
|
||||||
storageAddress + i * storageType - ramOffset,
|
storageAddress + i * storageType - ramOffset,
|
||||||
storageType));
|
storageType,
|
||||||
|
signed));
|
||||||
}
|
}
|
||||||
|
|
||||||
data[i].setPreferredSize(new Dimension(cellWidth, cellHeight));
|
data[i].setPreferredSize(new Dimension(cellWidth, cellHeight));
|
||||||
|
@ -512,6 +515,14 @@ public abstract class Table extends JPanel implements Serializable {
|
||||||
this.storageType = storageType;
|
this.storageType = storageType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSignedData() {
|
||||||
|
return signed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignedData(boolean signed) {
|
||||||
|
this.signed = signed;
|
||||||
|
}
|
||||||
|
|
||||||
public int getEndian() {
|
public int getEndian() {
|
||||||
return endian;
|
return endian;
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,8 @@ public class Table3D extends Table {
|
||||||
RomAttributeParser.parseByteValue(input,
|
RomAttributeParser.parseByteValue(input,
|
||||||
endian,
|
endian,
|
||||||
storageAddress + offset * storageType - ramOffset,
|
storageAddress + offset * storageType - ramOffset,
|
||||||
storageType));
|
storageType,
|
||||||
|
signed));
|
||||||
}
|
}
|
||||||
|
|
||||||
// show locked cell
|
// show locked cell
|
||||||
|
|
|
@ -34,7 +34,14 @@ public class TablePropertyPanel extends javax.swing.JPanel {
|
||||||
unit.setText(table.getScale().getUnit());
|
unit.setText(table.getScale().getUnit());
|
||||||
byteToReal.setText(table.getScale().getExpression());
|
byteToReal.setText(table.getScale().getExpression());
|
||||||
realToByte.setText(table.getScale().getByteExpression());
|
realToByte.setText(table.getScale().getByteExpression());
|
||||||
storageSize.setText("uint" + (table.getStorageType() * 8));
|
String intType;
|
||||||
|
if (table.isSignedData()) {
|
||||||
|
intType = "int";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
intType = "uint";
|
||||||
|
}
|
||||||
|
storageSize.setText(intType + (table.getStorageType() * 8));
|
||||||
storageAddress.setText("0x" + Integer.toHexString(table.getStorageAddress()));
|
storageAddress.setText("0x" + Integer.toHexString(table.getStorageAddress()));
|
||||||
|
|
||||||
if (table.getEndian() == Table.ENDIAN_BIG) {
|
if (table.getEndian() == Table.ENDIAN_BIG) {
|
||||||
|
|
|
@ -381,6 +381,7 @@ public final class DOMRomUnmarshaller {
|
||||||
|
|
||||||
table.setCategory(unmarshallAttribute(tableNode, "category", table.getCategory()));
|
table.setCategory(unmarshallAttribute(tableNode, "category", table.getCategory()));
|
||||||
table.setStorageType(RomAttributeParser.parseStorageType(unmarshallAttribute(tableNode, "storagetype", String.valueOf(table.getStorageType()))));
|
table.setStorageType(RomAttributeParser.parseStorageType(unmarshallAttribute(tableNode, "storagetype", String.valueOf(table.getStorageType()))));
|
||||||
|
table.setSignedData(RomAttributeParser.parseStorageDataSign(unmarshallAttribute(tableNode, "storagetype", String.valueOf(table.getStorageType()))));
|
||||||
table.setEndian(RomAttributeParser.parseEndian(unmarshallAttribute(tableNode, "endian", String.valueOf(table.getEndian()))));
|
table.setEndian(RomAttributeParser.parseEndian(unmarshallAttribute(tableNode, "endian", String.valueOf(table.getEndian()))));
|
||||||
table.setStorageAddress(RomAttributeParser.parseHexString(unmarshallAttribute(tableNode, "storageaddress", String.valueOf(table.getStorageAddress()))));
|
table.setStorageAddress(RomAttributeParser.parseHexString(unmarshallAttribute(tableNode, "storageaddress", String.valueOf(table.getStorageAddress()))));
|
||||||
table.setDescription(unmarshallAttribute(tableNode, "description", table.getDescription()));
|
table.setDescription(unmarshallAttribute(tableNode, "description", table.getDescription()));
|
||||||
|
|
|
@ -31,6 +31,8 @@ import static com.romraider.maps.Table.TABLE_2D;
|
||||||
import static com.romraider.maps.Table.TABLE_3D;
|
import static com.romraider.maps.Table.TABLE_3D;
|
||||||
import static com.romraider.maps.Table.TABLE_X_AXIS;
|
import static com.romraider.maps.Table.TABLE_X_AXIS;
|
||||||
import static com.romraider.maps.Table.TABLE_Y_AXIS;
|
import static com.romraider.maps.Table.TABLE_Y_AXIS;
|
||||||
|
|
||||||
|
import java.nio.BufferOverflowException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
|
@ -42,9 +44,11 @@ public final class RomAttributeParser {
|
||||||
public static int parseEndian(String input) {
|
public static int parseEndian(String input) {
|
||||||
if (input.equalsIgnoreCase("big") || input.equalsIgnoreCase(String.valueOf(ENDIAN_BIG))) {
|
if (input.equalsIgnoreCase("big") || input.equalsIgnoreCase(String.valueOf(ENDIAN_BIG))) {
|
||||||
return ENDIAN_BIG;
|
return ENDIAN_BIG;
|
||||||
} else if (input.equalsIgnoreCase("little") || input.equalsIgnoreCase(String.valueOf(ENDIAN_LITTLE))) {
|
}
|
||||||
|
else if (input.equalsIgnoreCase("little") || input.equalsIgnoreCase(String.valueOf(ENDIAN_LITTLE))) {
|
||||||
return ENDIAN_LITTLE;
|
return ENDIAN_LITTLE;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return ENDIAN_LITTLE;
|
return ENDIAN_LITTLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,9 +56,11 @@ public final class RomAttributeParser {
|
||||||
public static int parseHexString(String input) {
|
public static int parseHexString(String input) {
|
||||||
if (input.equals("0")) {
|
if (input.equals("0")) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (input.length() > 2 && input.substring(0, 2).equalsIgnoreCase("0x")) {
|
}
|
||||||
|
else if (input.length() > 2 && input.substring(0, 2).equalsIgnoreCase("0x")) {
|
||||||
return Integer.parseInt(input.substring(2), 16);
|
return Integer.parseInt(input.substring(2), 16);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return Integer.parseInt(input, 16);
|
return Integer.parseInt(input, 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,17 +68,32 @@ public final class RomAttributeParser {
|
||||||
public static int parseStorageType(String input) {
|
public static int parseStorageType(String input) {
|
||||||
if (input.equalsIgnoreCase("float")) {
|
if (input.equalsIgnoreCase("float")) {
|
||||||
return STORAGE_TYPE_FLOAT;
|
return STORAGE_TYPE_FLOAT;
|
||||||
} else if (input.startsWith("uint")) {
|
}
|
||||||
|
else if (input.startsWith("uint")) {
|
||||||
return Integer.parseInt(input.substring(4)) / 8;
|
return Integer.parseInt(input.substring(4)) / 8;
|
||||||
} else {
|
}
|
||||||
|
else if (input.startsWith("int")) {
|
||||||
|
return Integer.parseInt(input.substring(3)) / 8;
|
||||||
|
}
|
||||||
|
else {
|
||||||
return Integer.parseInt(input);
|
return Integer.parseInt(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean parseStorageDataSign(String input) {
|
||||||
|
if (input.startsWith("int")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int parseScaleType(String input) {
|
public static int parseScaleType(String input) {
|
||||||
if (input.equalsIgnoreCase("inverse")) {
|
if (input.equalsIgnoreCase("inverse")) {
|
||||||
return INVERSE;
|
return INVERSE;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return LINEAR;
|
return LINEAR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,54 +101,80 @@ public final class RomAttributeParser {
|
||||||
public static int parseTableType(String input) {
|
public static int parseTableType(String input) {
|
||||||
if (input.equalsIgnoreCase("3D") || input.equalsIgnoreCase(String.valueOf(TABLE_3D))) {
|
if (input.equalsIgnoreCase("3D") || input.equalsIgnoreCase(String.valueOf(TABLE_3D))) {
|
||||||
return TABLE_3D;
|
return TABLE_3D;
|
||||||
} else if (input.equalsIgnoreCase("2D") || input.equalsIgnoreCase(String.valueOf(TABLE_2D))) {
|
}
|
||||||
|
else if (input.equalsIgnoreCase("2D") || input.equalsIgnoreCase(String.valueOf(TABLE_2D))) {
|
||||||
return TABLE_2D;
|
return TABLE_2D;
|
||||||
} else if (input.equalsIgnoreCase("X Axis") || input.equalsIgnoreCase("Static X Axis") || input.equalsIgnoreCase(String.valueOf(TABLE_X_AXIS))) {
|
}
|
||||||
|
else if (input.equalsIgnoreCase("X Axis") || input.equalsIgnoreCase("Static X Axis") || input.equalsIgnoreCase(String.valueOf(TABLE_X_AXIS))) {
|
||||||
return TABLE_X_AXIS;
|
return TABLE_X_AXIS;
|
||||||
} else if (input.equalsIgnoreCase("Y Axis") || input.equalsIgnoreCase("Static Y Axis") || input.equalsIgnoreCase(String.valueOf(TABLE_Y_AXIS))) {
|
}
|
||||||
|
else if (input.equalsIgnoreCase("Y Axis") || input.equalsIgnoreCase("Static Y Axis") || input.equalsIgnoreCase(String.valueOf(TABLE_Y_AXIS))) {
|
||||||
return TABLE_Y_AXIS;
|
return TABLE_Y_AXIS;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return TABLE_1D;
|
return TABLE_1D;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int parseByteValue(byte[] input, int endian, int address, int length) throws ArrayIndexOutOfBoundsException {
|
public static long parseByteValue(byte[] input, int endian, int address, int length, boolean signed) throws ArrayIndexOutOfBoundsException {
|
||||||
try {
|
try {
|
||||||
int output = 0;
|
long output = 0L;
|
||||||
if (endian == ENDIAN_BIG) {
|
ByteBuffer bb = ByteBuffer.wrap(input, address, length);
|
||||||
for (int i = 0; i < length; i++) {
|
if (endian == ENDIAN_LITTLE) {
|
||||||
output += (input[address + i] & 0xff) << 8 * (length - i - 1);
|
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
}
|
}
|
||||||
} else { // little endian
|
switch (length) {
|
||||||
for (int i = 0; i < length; i++) {
|
case 1:
|
||||||
output += (input[address + length - i - 1] & 0xff) << 8 * (length - i - 1);
|
output = bb.get();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
output = bb.getShort();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
output = bb.getInt();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!signed) {
|
||||||
|
switch (length) {
|
||||||
|
case 1:
|
||||||
|
output = output & 0xff;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
output = output & 0xffff;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
output = output & 0xffffffffL;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
} catch (IndexOutOfBoundsException ex) {
|
||||||
throw new ArrayIndexOutOfBoundsException();
|
throw new IndexOutOfBoundsException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] parseIntegerValue(int input, int endian, int length) {
|
public static byte[] parseIntegerValue(int input, int endian, int length) {
|
||||||
byte[] byteArray = new byte[4];
|
try {
|
||||||
|
ByteBuffer bb = ByteBuffer.allocate(length);
|
||||||
byteArray[0] = (byte) ((input >> 24) & 0x000000FF);
|
if (endian == ENDIAN_LITTLE) {
|
||||||
byteArray[1] = (byte) ((input >> 16) & 0x0000FF);
|
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
byteArray[2] = (byte) ((input >> 8) & 0x00FF);
|
}
|
||||||
byteArray[3] = (byte) (input & 0xFF);
|
switch (length) {
|
||||||
|
case 1:
|
||||||
byte[] output = new byte[length];
|
bb.put((byte) input);
|
||||||
|
break;
|
||||||
for (int i = 0; i < length; i++) {
|
case 2:
|
||||||
if (endian == ENDIAN_BIG) {
|
bb.putShort((short) input);
|
||||||
//output[i] = byteArray[i + length];
|
break;
|
||||||
output[i] = byteArray[4 - length + i];
|
case 4:
|
||||||
} else { // little endian
|
bb.putInt(input);
|
||||||
output[length - 1 - i] = byteArray[4 - length + i];
|
break;
|
||||||
}
|
}
|
||||||
|
return bb.array();
|
||||||
|
}
|
||||||
|
catch (BufferOverflowException ex) {
|
||||||
|
throw new BufferOverflowException();
|
||||||
}
|
}
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int parseFileSize(String input) throws NumberFormatException {
|
public static int parseFileSize(String input) throws NumberFormatException {
|
||||||
|
@ -136,7 +183,8 @@ public final class RomAttributeParser {
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
if (input.substring(input.length() - 2).equalsIgnoreCase("kb")) {
|
if (input.substring(input.length() - 2).equalsIgnoreCase("kb")) {
|
||||||
return Integer.parseInt(input.substring(0, input.length() - 2)) * 1024;
|
return Integer.parseInt(input.substring(0, input.length() - 2)) * 1024;
|
||||||
} else if (input.substring(input.length() - 2).equalsIgnoreCase("mb")) {
|
}
|
||||||
|
else if (input.substring(input.length() - 2).equalsIgnoreCase("mb")) {
|
||||||
return Integer.parseInt(input.substring(0, input.length() - 2)) * 1024 * 1024;
|
return Integer.parseInt(input.substring(0, input.length() - 2)) * 1024 * 1024;
|
||||||
}
|
}
|
||||||
throw new NumberFormatException();
|
throw new NumberFormatException();
|
||||||
|
|
Loading…
Reference in New Issue