use of sw_emulator.software.MemoryDasm in project jc64 by ice00.
the class JLabelsDialog method searchAddress.
/**
* Search for a memory address (even as label) from the initial passed string
*
* @param initial the initial buffer to search for
* @return the address or -1 if not find
*/
protected int searchAddress(String initial) {
int addr = -1;
try {
// get the first word of the string
String str = initial;
str = str.contains(" ") ? str.split(" ")[0] : str;
if (str.length() == 4)
addr = Integer.decode("0x" + str);
else {
str = str.contains(":") ? str.split(":")[0] : str;
for (MemoryDasm memory : project.memory) {
if (str.equals(memory.dasmLocation) || str.equals(memory.userLocation)) {
addr = memory.address;
break;
}
}
}
} catch (Exception e) {
System.err.println(e);
}
return addr;
}
use of sw_emulator.software.MemoryDasm in project jc64 by ice00.
the class JDisassemblerFrame method getAreaCodeSize.
/**
* Get the hex size of the are around the given code memory location
*
* @param address the address to check
* @return the hex number string
*/
private String getAreaCodeSize(int address) {
MemoryDasm mem = project.memory[address];
int size = 1;
int i = address - 1;
while (i >= 0) {
if (project.memory[i].isCode)
size++;
else
break;
i--;
}
i = address + 1;
while (i <= 0xFFFF) {
if (project.memory[i].isCode)
size++;
else
break;
i++;
}
return Shared.ShortToExe(size);
}
use of sw_emulator.software.MemoryDasm in project jc64 by ice00.
the class JDisassemblerFrame method getAreaGarbageSize.
/**
* Get the hex size of the are around the given garbage memory location
*
* @param address the address to check
* @return the hex number string
*/
private String getAreaGarbageSize(int address) {
MemoryDasm mem = project.memory[address];
int size = 1;
int i = address - 1;
while (i >= 0) {
if (project.memory[i].isGarbage)
size++;
else
break;
i--;
}
i = address + 1;
while (i <= 0xFFFF) {
if (project.memory[i].isGarbage)
size++;
else
break;
i++;
}
return Shared.ShortToExe(size);
}
use of sw_emulator.software.MemoryDasm in project jc64 by ice00.
the class JDisassemblerFrame method subAssign.
/**
* Assing the given index in table to memory
*
* @param key the key table to assign
*/
private void subAssign(int index) {
MemoryDasm mem;
int[] rows = jTableMemory.getSelectedRows();
for (int i = 0; i < rows.length; i++) {
mem = project.memory[rows[i]];
mem.index = (byte) index;
}
dataTableModelMemory.fireTableDataChanged();
jTableMemory.clearSelection();
for (int i = 0; i < rows.length; i++) {
jTableMemory.addRowSelectionInterval(rows[i], rows[i]);
}
}
use of sw_emulator.software.MemoryDasm in project jc64 by ice00.
the class JDisassemblerFrame method projectMerge.
/**
* Collaborative merge of another user contribution
*/
private void projectMerge() {
if (project == null) {
JOptionPane.showMessageDialog(this, "You must be inside a project to merge it with another!", "Information", JOptionPane.WARNING_MESSAGE);
return;
}
int retVal = projectMergeFile.showOpenDialog(this);
if (retVal == JFileChooser.APPROVE_OPTION) {
File mergeFile = projectMergeFile.getSelectedFile();
Project mergeProject = new Project();
if (!FileManager.instance.readProjectFile(mergeFile, mergeProject)) {
JOptionPane.showMessageDialog(this, "Error reading project file", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
// test that the projects are of the same
if ((Arrays.hashCode(mergeProject.inB) != Arrays.hashCode(project.inB))) {
JOptionPane.showMessageDialog(this, "Byte data of the projects are different: they are not of the same source", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (project.fileType == FileType.CRT && project.chip != mergeProject.chip) {
JOptionPane.showMessageDialog(this, "You are disassembe different chip inside a CRT image", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (MPR.hashCode(mergeProject.mpr) != MPR.hashCode(project.mpr)) {
JOptionPane.showMessageDialog(this, "Byte data of MPR in projects are different: they are not of the same source", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
// take name/description from secondary only if not present in primary
if (project.name == null || "".equals(project.name))
project.name = mergeProject.name;
if (project.description == null || "".equals(project.description))
project.description = mergeProject.description;
// copy constant
for (int i = 0; i < Constant.COLS; i++) {
for (int j = 0; i < Constant.ROWS; j++) {
if (project.constant.table[i][j] == null || "".equals(project.constant.table[i][j]))
project.constant.table[i][j] = mergeProject.constant.table[i][j];
}
}
MemoryDasm memProject;
MemoryDasm memMerge;
// scan all memory locations
for (int i = 0; i < project.memory.length; i++) {
memProject = project.memory[i];
memMerge = mergeProject.memory[i];
// apply secondary information if primary are not defined
if (memProject.userBlockComment == null || "".equals(memProject.userBlockComment))
memProject.userBlockComment = memMerge.userBlockComment;
if (memProject.userComment == null || "".equals(memProject.userComment))
memProject.userComment = memMerge.userComment;
if (memProject.userLocation == null || "".equals(memProject.userLocation))
memProject.userLocation = memMerge.userLocation;
if (memProject.isInside) {
if (!memProject.isCode && !memProject.isData && !memProject.isGarbage) {
memProject.isCode = memMerge.isCode;
memProject.isData = memMerge.isData;
memProject.isGarbage = memMerge.isGarbage;
}
if (memProject.related == -1) {
memProject.related = memMerge.related;
memProject.type = memMerge.type;
}
if (memProject.dataType != DataType.NONE)
memProject.dataType = memMerge.dataType;
if (memProject.index == -1)
memProject.index = memMerge.index;
}
}
// check relocate
if (project.relocates == null)
project.relocates = mergeProject.relocates;
// check patch
if (project.patches == null)
project.patches = mergeProject.patches;
else if (mergeProject.patches != null) {
// copy the value in the list
Patch[] patches2 = new Patch[project.patches.length + mergeProject.patches.length];
System.arraycopy(project.patches, 0, patches2, 0, project.patches.length);
for (int i = 0; i < mergeProject.patches.length; i++) {
patches2[project.patches.length + i] = mergeProject.patches[i];
}
project.patches = patches2;
}
dataTableModelMemory.fireTableDataChanged();
}
}
Aggregations