extended rom support

git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@790 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
kascade 2007-10-18 13:02:10 +00:00
parent c57d198e46
commit d719427753
2 changed files with 42 additions and 36 deletions

View File

@ -31,13 +31,8 @@ import static enginuity.util.TableAxisUtil.getLiveDataRangeForAxis;
import enginuity.xml.RomAttributeParser; import enginuity.xml.RomAttributeParser;
import static javax.swing.BorderFactory.createLineBorder; import static javax.swing.BorderFactory.createLineBorder;
import javax.swing.JLabel; import javax.swing.*;
import javax.swing.JPanel; import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.datatransfer.UnsupportedFlavorException;
@ -50,6 +45,7 @@ public class Table3D extends Table {
private Table1D xAxis = new Table1D(new Settings()); private Table1D xAxis = new Table1D(new Settings());
private Table1D yAxis = new Table1D(new Settings()); private Table1D yAxis = new Table1D(new Settings());
private DataCell[][] data = new DataCell[1][1]; private DataCell[][] data = new DataCell[1][1];
private boolean columnBased = false;
private boolean swapXY = false; private boolean swapXY = false;
private boolean flipX = false; private boolean flipX = false;
private boolean flipY = false; private boolean flipY = false;
@ -76,7 +72,15 @@ public class Table3D extends Table {
this.yAxis = yAxis; this.yAxis = yAxis;
} }
public boolean isSwapXY() { public boolean getColumnBased() {
return columnBased;
}
public void setColumnBased(boolean columnBased) {
this.columnBased = columnBased;
}
public boolean getSwapXY() {
return swapXY; return swapXY;
} }
@ -139,17 +143,18 @@ public class Table3D extends Table {
throw new ArrayIndexOutOfBoundsException(); throw new ArrayIndexOutOfBoundsException();
} }
for (int i = 0; i < xAxis.getDataSize(); i++) { for (int x = 0; x < xAxis.getDataSize(); x++) {
centerPanel.add(xAxis.getDataCell(i)); centerPanel.add(xAxis.getDataCell(x));
} }
int offset = 0; int offset = 0;
for (int x = 0; x < yAxis.getDataSize(); x++) { int iMax = columnBased ? xAxis.getDataSize() : yAxis.getDataSize();
centerPanel.add(yAxis.getDataCell(x)); int jMax = columnBased ? yAxis.getDataSize() : xAxis.getDataSize();
for (int y = 0; y < xAxis.getDataSize(); y++) { for (int i = 0; i < iMax; i++) {
data[y][x] = new DataCell(scales.get(scaleIndex), settings.getCellSize()); for (int j = 0; j < jMax; j++) {
data[y][x].setTable(this); data[i][j] = new DataCell(scales.get(scaleIndex), settings.getCellSize());
data[i][j].setTable(this);
// populate data cells // populate data cells
if (storageType == STORAGE_TYPE_FLOAT) { //float storage type if (storageType == STORAGE_TYPE_FLOAT) { //float storage type
@ -158,10 +163,10 @@ public class Table3D extends Table {
byteValue[1] = input[storageAddress + offset * 4 - ramOffset + 1]; byteValue[1] = input[storageAddress + offset * 4 - ramOffset + 1];
byteValue[2] = input[storageAddress + offset * 4 - ramOffset + 2]; byteValue[2] = input[storageAddress + offset * 4 - ramOffset + 2];
byteValue[3] = input[storageAddress + offset * 4 - ramOffset + 3]; byteValue[3] = input[storageAddress + offset * 4 - ramOffset + 3];
data[y][x].setBinValue(RomAttributeParser.byteToFloat(byteValue, endian)); data[i][j].setBinValue(RomAttributeParser.byteToFloat(byteValue, endian));
} else { // integer storage type } else { // integer storage type
data[y][x].setBinValue( data[i][j].setBinValue(
RomAttributeParser.parseByteValue(input, RomAttributeParser.parseByteValue(input,
endian, endian,
storageAddress + offset * storageType - ramOffset, storageAddress + offset * storageType - ramOffset,
@ -170,17 +175,23 @@ public class Table3D extends Table {
// show locked cell // show locked cell
if (tempLock) { if (tempLock) {
data[y][x].setForeground(Color.GRAY); data[i][j].setForeground(Color.GRAY);
} }
centerPanel.add(data[y][x]); data[i][j].setXCoord(i);
data[y][x].setXCoord(y); data[i][j].setYCoord(j);
data[y][x].setYCoord(x); data[i][j].setOriginalValue(data[i][j].getBinValue());
data[y][x].setOriginalValue(data[y][x].getBinValue());
offset++; offset++;
} }
} }
for (int y = 0; y < yAxis.getDataSize(); y++) {
centerPanel.add(yAxis.getDataCell(y));
for (int x = 0; x < xAxis.getDataSize(); x++) {
centerPanel.add(data[x][y]);
}
}
// reset locked status // reset locked status
locked = tempLock; locked = tempLock;
@ -484,18 +495,20 @@ public class Table3D extends Table {
binData = yAxis.saveFile(binData); binData = yAxis.saveFile(binData);
int offset = 0; int offset = 0;
for (int x = 0; x < yAxis.getDataSize(); x++) { int iMax = columnBased ? xAxis.getDataSize() : yAxis.getDataSize();
for (int y = 0; y < xAxis.getDataSize(); y++) { int jMax = columnBased ? yAxis.getDataSize() : xAxis.getDataSize();
for (int i = 0; i < iMax; i++) {
for (int j = 0; j < jMax; j++) {
// determine output byte values // determine output byte values
byte[] output; byte[] output;
if (storageType != STORAGE_TYPE_FLOAT) { if (storageType != STORAGE_TYPE_FLOAT) {
output = RomAttributeParser.parseIntegerValue((int) data[y][x].getBinValue(), endian, storageType); output = RomAttributeParser.parseIntegerValue((int) data[i][j].getBinValue(), endian, storageType);
for (int z = 0; z < storageType; z++) { for (int z = 0; z < storageType; z++) {
binData[offset * storageType + z + storageAddress - ramOffset] = output[z]; binData[offset * storageType + z + storageAddress - ramOffset] = output[z];
} }
} else { // float } else { // float
output = RomAttributeParser.floatToByte((float) data[y][x].getBinValue(), endian); output = RomAttributeParser.floatToByte((float) data[i][j].getBinValue(), endian);
for (int z = 0; z < 4; z++) { for (int z = 0; z < 4; z++) {
binData[offset * 4 + z + storageAddress - ramOffset] = output[z]; binData[offset * 4 + z + storageAddress - ramOffset] = output[z];
} }

View File

@ -4,15 +4,7 @@ package enginuity.xml;
import enginuity.ECUEditor; import enginuity.ECUEditor;
import enginuity.Settings; import enginuity.Settings;
import enginuity.maps.DataCell; import enginuity.maps.*;
import enginuity.maps.Rom;
import enginuity.maps.RomID;
import enginuity.maps.Scale;
import enginuity.maps.Table;
import enginuity.maps.Table1D;
import enginuity.maps.Table2D;
import enginuity.maps.Table3D;
import enginuity.maps.TableSwitch;
import enginuity.swing.DebugPanel; import enginuity.swing.DebugPanel;
import enginuity.swing.JProgressPane; import enginuity.swing.JProgressPane;
import enginuity.util.LogManager; import enginuity.util.LogManager;
@ -25,7 +17,7 @@ import static org.w3c.dom.Node.ELEMENT_NODE;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import javax.management.modelmbean.XMLParseException; import javax.management.modelmbean.XMLParseException;
import javax.swing.JOptionPane; import javax.swing.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -373,6 +365,7 @@ public final class DOMRomUnmarshaller {
table.setLogParam(unmarshallAttribute(tableNode, "logparam", table.getLogParam())); table.setLogParam(unmarshallAttribute(tableNode, "logparam", table.getLogParam()));
if (table.getType() == Table.TABLE_3D) { if (table.getType() == Table.TABLE_3D) {
((Table3D) table).setColumnBased(unmarshallAttribute(tableNode, "colbased", ((Table3D) table).getColumnBased()));
((Table3D) table).setFlipX(unmarshallAttribute(tableNode, "flipx", ((Table3D) table).getFlipX())); ((Table3D) table).setFlipX(unmarshallAttribute(tableNode, "flipx", ((Table3D) table).getFlipX()));
((Table3D) table).setFlipY(unmarshallAttribute(tableNode, "flipy", ((Table3D) table).getFlipY())); ((Table3D) table).setFlipY(unmarshallAttribute(tableNode, "flipy", ((Table3D) table).getFlipY()));
((Table3D) table).setSizeX(unmarshallAttribute(tableNode, "sizex", ((Table3D) table).getSizeX())); ((Table3D) table).setSizeX(unmarshallAttribute(tableNode, "sizex", ((Table3D) table).getSizeX()));