diff --git a/src/main/java/oldipspatcher/DlgMain.java b/src/main/java/oldipspatcher/DlgMain.java new file mode 100644 index 0000000..8614039 --- /dev/null +++ b/src/main/java/oldipspatcher/DlgMain.java @@ -0,0 +1,225 @@ +package oldipspatcher; + +import javax.swing.*; +import javax.swing.border.*; +import java.awt.*; +import java.awt.event.*; +import java.io.File; +import java.io.IOException; + +public class DlgMain extends JDialog { + boolean patchzipped; + boolean filezipped; + private JPanel jPanel8; + private JPanel jPanel7; + private JPanel jPanel6; + private JPanel jPanel5; + private JPanel jPanel4; + private JPanel jPanel3; + private JPanel jPanel2; + private JPanel jPanel1; + private JComboBox CmbFile; + private JButton BtnPatch; + private JCheckBox ChkBackup; + private JCheckBox ChkLog; + private JPanel jPanel11; + private JPanel jPanel10; + private JButton BtnCancel; + private JTabbedPane jTabbedPane1; + private JComboBox CmbPatch; + private JLabel jLabel3; + private JLabel jLabel2; + private JLabel jLabel1; + private JButton BtnBrowsePatch; + private JButton BtnBrowseFile; + + public DlgMain(Frame parent, boolean modal) { + super(parent, modal); + this.initComponents(); + } + + private void initComponents() { + this.jTabbedPane1 = new JTabbedPane(); + this.jPanel1 = new JPanel(); + this.jPanel3 = new JPanel(); + this.CmbFile = new JComboBox(); + this.BtnBrowseFile = new JButton(); + this.jPanel4 = new JPanel(); + this.CmbPatch = new JComboBox(); + this.BtnBrowsePatch = new JButton(); + this.jPanel2 = new JPanel(); + this.jPanel6 = new JPanel(); + this.jPanel11 = new JPanel(); + this.ChkLog = new JCheckBox(); + this.ChkBackup = new JCheckBox(); + this.jPanel7 = new JPanel(); + this.jPanel8 = new JPanel(); + this.jPanel10 = new JPanel(); + this.jLabel1 = new JLabel(); + this.jLabel2 = new JLabel(); + this.jLabel3 = new JLabel(); + this.jPanel5 = new JPanel(); + this.BtnPatch = new JButton(); + this.BtnCancel = new JButton(); + this.setDefaultCloseOperation(2); + this.setTitle("JIPS 3.0"); + this.setFont(new Font("Dialog", 1, 12)); + this.addWindowListener(new WindowAdapter() { + public void windowOpened(WindowEvent evt) { + DlgMain.this.formWindowOpened(evt); + } + + public void windowClosing(WindowEvent evt) { + DlgMain.this.closeDialog(evt); + } + }); + this.jPanel1.setLayout(new GridLayout(2, 1)); + this.jPanel3.setLayout(new BoxLayout(this.jPanel3, 0)); + this.jPanel3.setBorder(new TitledBorder((Border)null, "File To Patch:", 0, 0, new Font("Dialog", 1, 12))); + this.CmbFile.setFont(new Font("Dialog", 0, 12)); + this.CmbFile.setMaximumSize(new Dimension(800, 26)); + this.CmbFile.setMinimumSize(new Dimension(180, 26)); + this.jPanel3.add(this.CmbFile); + this.BtnBrowseFile.setText("..."); + this.BtnBrowseFile.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + DlgMain.this.BtnBrowseFileActionPerformed(evt); + } + }); + this.jPanel3.add(this.BtnBrowseFile); + this.jPanel1.add(this.jPanel3); + this.jPanel4.setLayout(new BoxLayout(this.jPanel4, 0)); + this.jPanel4.setBorder(new TitledBorder((Border)null, "Patch File:", 0, 2, new Font("Dialog", 1, 12))); + this.CmbPatch.setFont(new Font("Dialog", 0, 12)); + this.CmbPatch.setMaximumSize(new Dimension(32767, 26)); + this.CmbPatch.setMinimumSize(new Dimension(180, 26)); + this.jPanel4.add(this.CmbPatch); + this.BtnBrowsePatch.setText("..."); + this.BtnBrowsePatch.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + DlgMain.this.BtnBrowsePatchActionPerformed(evt); + } + }); + this.jPanel4.add(this.BtnBrowsePatch); + this.jPanel1.add(this.jPanel4); + this.jTabbedPane1.addTab("Patching", (Icon)null, this.jPanel1, ""); + this.jPanel2.setLayout(new BoxLayout(this.jPanel2, 0)); + this.jPanel6.setBorder(new TitledBorder((Border)null, "Options:", 0, 0, new Font("Dialog", 1, 12))); + this.jPanel6.setFont(new Font("Dialog", 1, 12)); + this.jPanel11.setLayout(new GridLayout(2, 1)); + this.ChkLog.setSelected(true); + this.ChkLog.setText("Log File"); + this.jPanel11.add(this.ChkLog); + this.ChkBackup.setSelected(true); + this.ChkBackup.setText("Backup Copy"); + this.jPanel11.add(this.ChkBackup); + this.jPanel6.add(this.jPanel11); + this.jPanel2.add(this.jPanel6); + this.jTabbedPane1.addTab("Options", (Icon)null, this.jPanel2, ""); + this.jPanel7.setLayout(new BorderLayout()); + this.jPanel8.setBackground(Color.black); + this.jPanel10.setLayout(new GridLayout(3, 1)); + this.jPanel10.setBackground(Color.black); + this.jLabel1.setBackground(Color.black); + this.jLabel1.setFont(new Font("Dialog", 1, 36)); + this.jLabel1.setForeground(new Color(153, 0, 153)); + this.jLabel1.setHorizontalAlignment(0); + this.jLabel1.setText("JIPS 3.0"); + this.jLabel1.setOpaque(true); + this.jPanel10.add(this.jLabel1); + this.jLabel2.setFont(new Font("Dialog", 0, 12)); + this.jLabel2.setForeground(new Color(255, 255, 255)); + this.jLabel2.setHorizontalAlignment(0); + this.jLabel2.setText("Copyright (C) 1998-2002 Z.e.r.o and ZeroSoft"); + this.jLabel2.setHorizontalTextPosition(0); + this.jPanel10.add(this.jLabel2); + this.jLabel3.setFont(new Font("Dialog", 0, 12)); + this.jLabel3.setForeground(new Color(102, 153, 255)); + this.jLabel3.setHorizontalAlignment(0); + this.jLabel3.setText("http://zerosoft.zophar.net"); + this.jPanel10.add(this.jLabel3); + this.jPanel8.add(this.jPanel10); + this.jPanel7.add(this.jPanel8, "Center"); + this.jTabbedPane1.addTab("About", (Icon)null, this.jPanel7, ""); + this.getContentPane().add(this.jTabbedPane1, "Center"); + this.BtnPatch.setText("Patch!"); + this.BtnPatch.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + DlgMain.this.BtnPatchActionPerformed(evt); + } + }); + this.jPanel5.add(this.BtnPatch); + this.BtnCancel.setText("Cancel"); + this.BtnCancel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + DlgMain.this.BtnCancelActionPerformed(evt); + } + }); + this.jPanel5.add(this.BtnCancel); + this.getContentPane().add(this.jPanel5, "South"); + this.pack(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + Dimension dialogSize = this.getSize(); + this.setLocation((screenSize.width - dialogSize.width) / 2, (screenSize.height - dialogSize.height) / 2); + } + + private void formWindowOpened(WindowEvent evt) { + } + + private void BtnBrowsePatchActionPerformed(ActionEvent evt) { + try { + this.patchzipped = this.Browse(this.CmbPatch); + } catch (Exception var3) { + ; + } + + } + + private void BtnBrowseFileActionPerformed(ActionEvent evt) { + try { + this.filezipped = this.Browse(this.CmbFile); + } catch (Exception var3) { + ; + } + + } + + private void BtnCancelActionPerformed(ActionEvent evt) { + System.exit(0); + } + + private void BtnPatchActionPerformed(ActionEvent evt) { + try { + IPSTool ips = new IPSTool(this, new File(this.CmbFile.getSelectedItem().toString()), new File(this.CmbPatch.getSelectedItem().toString()), this.ChkLog.isSelected(), this.ChkBackup.isSelected()); + ips.patch(); + } catch (IOException var5) { + ; + } + + } + + private void closeDialog(WindowEvent evt) { + this.setVisible(false); + this.dispose(); + } + + public static void main(String[] args) { + (new DlgMain(new JFrame(), true)).show(); + } + + boolean isaZip(File file) { + return file.isFile() && file.getName().toLowerCase().endsWith(".zip"); + } + + public boolean Browse(JComboBox Combo) throws Exception { + JFileChooser chooser = new JFileChooser(); + int returnVal = chooser.showOpenDialog(this); + if (returnVal == 0) { + File SelectedFile = chooser.getSelectedFile(); + Combo.addItem(SelectedFile.getPath()); + return false; + } else { + return false; + } + } +} diff --git a/src/main/java/oldipspatcher/IPSTool.java b/src/main/java/oldipspatcher/IPSTool.java new file mode 100644 index 0000000..edcf45f --- /dev/null +++ b/src/main/java/oldipspatcher/IPSTool.java @@ -0,0 +1,166 @@ +package oldipspatcher; + +import java.awt.Window; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.RandomAccessFile; +import javax.swing.JDialog; +import javax.swing.JOptionPane; + +public class IPSTool { + static int IPSE_Patch = 1; + static int IPSE_File = 2; + Window parent; + JDialog DlgProgress; + int OrigIdx = -1; + int PatchIdx = -1; + RandomAccessFile OrigFile; + RandomAccessFile PatchFile; + RandomAccessFile LogFile; + int Address; + int NumBytes; + int RLEBytes; + int TotalChunks; + char RLEByte; + byte[] Buffer; + boolean log; + boolean backup; + + public IPSTool(Window p, File file, File patch, boolean filezip, boolean patchzip, boolean Log, boolean Backup) throws IOException { + this.init(p, file, patch, Log, Backup); + } + + public IPSTool(Window p, File file, File patch, boolean Log, boolean Backup) throws IOException { + this.init(p, file, patch, Log, Backup); + } + + public void init(Window p, File file, File patch, boolean Log, boolean Backup) throws IOException { + this.PatchFile = new RandomAccessFile(patch, "r"); + this.OrigFile = new RandomAccessFile(file, "rw"); + this.TotalChunks = 0; + this.Address = 0; + this.NumBytes = 0; + this.RLEBytes = 0; + this.log = Log; + this.parent = p; + if (this.log) { + this.LogFile = new RandomAccessFile(patch.getParent() + File.separatorChar + "log.txt", "rw"); + } + + this.backup = Backup; + if (this.backup) { + File outputFile = new File(file.getPath() + ".bak"); + FileReader in = new FileReader(file); + FileWriter out = new FileWriter(outputFile.getPath(), false); + + int c; + while((c = in.read()) != -1) { + out.write(c); + } + + in.close(); + out.close(); + } + + } + + void GetNumBytes() throws IOException { + int b1 = this.PatchFile.readUnsignedByte(); + int b2 = this.PatchFile.readUnsignedByte(); + this.NumBytes = b2; + this.NumBytes += b1 * 256; + if (this.NumBytes == 0) { + this.GetRLE(); + } + + } + + boolean GetAddress() throws IOException { + if (this.PatchIdx == -1) { + int a1 = this.PatchFile.readUnsignedByte(); + int a2 = this.PatchFile.readUnsignedByte(); + int a3 = this.PatchFile.readUnsignedByte(); + if (a1 == 69 && a2 == 79 && a3 == 70) { + return false; + } + + ++this.TotalChunks; + this.Address = 0; + this.Address = a3; + this.Address += a2 * 256; + this.Address += a1 * 65536; + } + + return true; + } + + boolean isaIPS() throws IOException { + this.Buffer = new byte[5]; + this.PatchFile.read(this.Buffer); + return this.Buffer[0] == 80 && this.Buffer[1] == 65 && this.Buffer[2] == 84 && this.Buffer[3] == 67 && this.Buffer[4] == 72; + } + + void GetChunk() throws IOException { + this.Buffer = new byte[this.NumBytes]; + this.PatchFile.read(this.Buffer); + } + + void ApplyPatch() throws IOException { + this.OrigFile.seek((long)this.Address); + this.OrigFile.write(this.Buffer, 0, this.NumBytes); + } + + void ApplyRLE() throws IOException { + this.OrigFile.seek((long)this.Address); + + for(int i = 0; i < this.NumBytes; ++i) { + this.OrigFile.write(this.RLEByte); + } + + } + + void GetRLE() throws IOException { + int r1 = this.PatchFile.readUnsignedByte(); + int r2 = this.PatchFile.readUnsignedByte(); + int rb = this.PatchFile.readUnsignedByte(); + this.RLEBytes = r2; + this.RLEBytes += r1 * 256; + this.RLEByte = (char)rb; + } + + public void patch() { + try { + if (this.isaIPS()) { + if (this.log) { + this.LogFile.writeBytes("JIPS 3.0 Logfile\nTo have news about JIPS and other ZeroSoft Projects\nvisit: http://zerosoft.zophar.net\n\n"); + } + + while(this.GetAddress()) { + this.GetNumBytes(); + if (this.NumBytes != 0) { + this.GetChunk(); + } + + if (this.NumBytes != 0) { + this.ApplyPatch(); + if (this.log) { + this.LogFile.writeBytes("Chunk number: " + Integer.toString(this.TotalChunks) + " Offset: " + Integer.toHexString(this.Address) + " Bytes: " + Integer.toHexString(this.NumBytes) + "\n"); + } + } else { + this.ApplyRLE(); + if (this.log) { + this.LogFile.writeBytes("Chunk number: " + Integer.toString(this.TotalChunks) + " Offset: " + Integer.toHexString(this.Address) + " Bytes: " + Integer.toHexString(this.NumBytes) + " RLE char: " + Integer.toHexString(this.RLEByte) + " Lenght: " + Integer.toString(this.RLEBytes) + "\n"); + } + } + } + + JOptionPane.showMessageDialog(this.parent, "Patching Complete!\nPatches applied: " + this.TotalChunks); + } + } catch (IOException var2) { + JOptionPane.showMessageDialog(this.parent, "An error occurred during patching:\n" + var2.getMessage()); + } + + } +} diff --git a/src/main/kotlin/ipspatcher/IPSTool.kt b/src/main/kotlin/ipspatcher/IPSTool.kt deleted file mode 100644 index 9825d0d..0000000 --- a/src/main/kotlin/ipspatcher/IPSTool.kt +++ /dev/null @@ -1,179 +0,0 @@ -package ipspatcher - -import java.awt.Window -import java.io.File -import java.io.FileReader -import java.io.FileWriter -import java.io.IOException -import java.io.RandomAccessFile -import javax.swing.JDialog -import javax.swing.JOptionPane - -class IPSTool { - internal var parent: Window - internal var DlgProgress: JDialog? = null - internal var OrigIdx = -1 - internal var PatchIdx = -1 - internal var OrigFile: RandomAccessFile - internal var PatchFile: RandomAccessFile - internal var LogFile: RandomAccessFile - internal var Address: Int = 0 - internal var NumBytes: Int = 0 - internal var RLEBytes: Int = 0 - internal var TotalChunks: Int = 0 - internal var RLEByte: Char = ' ' - internal var Buffer: ByteArray - internal var log: Boolean = false - internal var backup: Boolean = false - - @Throws(IOException::class) - constructor(p: Window, file: File, patch: File, filezip: Boolean, patchzip: Boolean, Log: Boolean, Backup: Boolean) { - this.init(p, file, patch, Log, Backup) - } - - @Throws(IOException::class) - constructor(p: Window, file: File, patch: File, Log: Boolean, Backup: Boolean) { - this.init(p, file, patch, Log, Backup) - } - - @Throws(IOException::class) - fun init(p: Window, file: File, patch: File, Log: Boolean, Backup: Boolean) { - this.PatchFile = RandomAccessFile(patch, "r") - this.OrigFile = RandomAccessFile(file, "rw") - this.TotalChunks = 0 - this.Address = 0 - this.NumBytes = 0 - this.RLEBytes = 0 - this.log = Log - this.parent = p - if (this.log) { - this.LogFile = RandomAccessFile(patch.parent + File.separatorChar + "log.txt", "rw") - } - - this.backup = Backup - if (this.backup) { - val outputFile = File(file.path + ".bak") - val `in` = FileReader(file) - val out = FileWriter(outputFile.path, false) - - var c: Int - while ((c = `in`.read()) != -1) { - out.write(c) - } - - `in`.close() - out.close() - } - - } - - @Throws(IOException::class) - internal fun GetNumBytes() { - val b1 = this.PatchFile.readUnsignedByte() - val b2 = this.PatchFile.readUnsignedByte() - this.NumBytes = b2 - this.NumBytes += b1 * 256 - if (this.NumBytes == 0) { - this.GetRLE() - } - - } - - @Throws(IOException::class) - internal fun GetAddress(): Boolean { - if (this.PatchIdx == -1) { - val a1 = this.PatchFile.readUnsignedByte() - val a2 = this.PatchFile.readUnsignedByte() - val a3 = this.PatchFile.readUnsignedByte() - if (a1 == 69 && a2 == 79 && a3 == 70) { - return false - } - - ++this.TotalChunks - this.Address = 0 - this.Address = a3 - this.Address += a2 * 256 - this.Address += a1 * 65536 - } - - return true - } - - @Throws(IOException::class) - internal fun isaIPS(): Boolean { - this.Buffer = ByteArray(5) - this.PatchFile.read(this.Buffer) - return this.Buffer[0].toInt() == 80 && this.Buffer[1].toInt() == 65 && this.Buffer[2].toInt() == 84 && this.Buffer[3].toInt() == 67 && this.Buffer[4].toInt() == 72 - } - - @Throws(IOException::class) - internal fun GetChunk() { - this.Buffer = ByteArray(this.NumBytes) - this.PatchFile.read(this.Buffer) - } - - @Throws(IOException::class) - internal fun ApplyPatch() { - this.OrigFile.seek(this.Address.toLong()) - this.OrigFile.write(this.Buffer, 0, this.NumBytes) - } - - @Throws(IOException::class) - internal fun ApplyRLE() { - this.OrigFile.seek(this.Address.toLong()) - - for (i in 0 until this.NumBytes) { - this.OrigFile.write(this.RLEByte.toInt()) - } - - } - - @Throws(IOException::class) - internal fun GetRLE() { - val r1 = this.PatchFile.readUnsignedByte() - val r2 = this.PatchFile.readUnsignedByte() - val rb = this.PatchFile.readUnsignedByte() - this.RLEBytes = r2 - this.RLEBytes += r1 * 256 - this.RLEByte = rb.toChar() - } - - fun patch() { - try { - if (this.isaIPS()) { - if (this.log) { - this.LogFile.writeBytes("JIPS 3.0 Logfile\nTo have news about JIPS and other ZeroSoft Projects\nvisit: http://zerosoft.zophar.net\n\n") - } - - while (this.GetAddress()) { - this.GetNumBytes() - if (this.NumBytes != 0) { - this.GetChunk() - } - - if (this.NumBytes != 0) { - this.ApplyPatch() - if (this.log) { - this.LogFile.writeBytes("Chunk number: " + Integer.toString(this.TotalChunks) + " Offset: " + Integer.toHexString(this.Address) + " Bytes: " + Integer.toHexString(this.NumBytes) + "\n") - } - } else { - this.ApplyRLE() - if (this.log) { - this.LogFile.writeBytes("Chunk number: " + Integer.toString(this.TotalChunks) + " Offset: " + Integer.toHexString(this.Address) + " Bytes: " + Integer.toHexString(this.NumBytes) + " RLE char: " + Integer.toHexString(this.RLEByte.toInt()) + " Lenght: " + Integer.toString(this.RLEBytes) + "\n") - } - } - } - - JOptionPane.showMessageDialog(this.parent, "Patching Complete!\nPatches applied: " + this.TotalChunks) - } - } catch (var2: IOException) { - JOptionPane.showMessageDialog(this.parent, "An error occurred during patching:\n" + var2.message) - } - - } - - companion object { - internal var IPSE_Patch = 1 - internal var IPSE_File = 2 - } -} diff --git a/src/main/kotlin/ipspatcher/IPSToolKt.kt b/src/main/kotlin/ipspatcher/IPSToolKt.kt new file mode 100644 index 0000000..1fc4e08 --- /dev/null +++ b/src/main/kotlin/ipspatcher/IPSToolKt.kt @@ -0,0 +1,179 @@ +package ipspatcher + +import java.awt.Window +import java.io.File +import java.io.FileReader +import java.io.FileWriter +import java.io.IOException +import java.io.RandomAccessFile +import javax.swing.JDialog +import javax.swing.JOptionPane + +//class IPSToolKt { +// internal var parent: Window? = null +// internal var DlgProgress: JDialog? = null +// internal var OrigIdx = -1 +// internal var PatchIdx = -1 +// internal var OrigFile: RandomAccessFile? = null +// internal var PatchFile: RandomAccessFile? = null +// internal var LogFile: RandomAccessFile? = null +// internal var Address: Int = 0 +// internal var NumBytes: Int = 0 +// internal var RLEBytes: Int = 0 +// internal var TotalChunks: Int = 0 +// internal var RLEByte: Char = ' ' +// internal var Buffer: ByteArray? = null +// internal var log: Boolean = false +// internal var backup: Boolean = false +// +// @Throws(IOException::class) +// constructor(p: Window, file: File, patch: File, filezip: Boolean, patchzip: Boolean, Log: Boolean, Backup: Boolean) { +// this.init(p, file, patch, Log, Backup) +// } +// +// @Throws(IOException::class) +// constructor(p: Window, file: File, patch: File, Log: Boolean, Backup: Boolean) { +// this.init(p, file, patch, Log, Backup) +// } +// +// @Throws(IOException::class) +// fun init(p: Window, file: File, patch: File, Log: Boolean, Backup: Boolean) { +// this.PatchFile = RandomAccessFile(patch, "r") +// this.OrigFile = RandomAccessFile(file, "rw") +// this.TotalChunks = 0 +// this.Address = 0 +// this.NumBytes = 0 +// this.RLEBytes = 0 +// this.log = Log +// this.parent = p +// if (this.log) { +// this.LogFile = RandomAccessFile(patch.parent + File.separatorChar + "log.txt", "rw") +// } +// +// this.backup = Backup +// if (this.backup) { +// val outputFile = File(file.path + ".bak") +// val `in` = FileReader(file) +// val out = FileWriter(outputFile.path, false) +// +// var c: Int +// while ((c = `in`.read()) != -1) { +// out.write(c) +// } +// +// `in`.close() +// out.close() +// } +// +// } +// +// @Throws(IOException::class) +// internal fun GetNumBytes() { +// val b1 = this.PatchFile.readUnsignedByte() +// val b2 = this.PatchFile.readUnsignedByte() +// this.NumBytes = b2 +// this.NumBytes += b1 * 256 +// if (this.NumBytes == 0) { +// this.GetRLE() +// } +// +// } +// +// @Throws(IOException::class) +// internal fun GetAddress(): Boolean { +// if (this.PatchIdx == -1) { +// val a1 = this.PatchFile.readUnsignedByte() +// val a2 = this.PatchFile.readUnsignedByte() +// val a3 = this.PatchFile.readUnsignedByte() +// if (a1 == 69 && a2 == 79 && a3 == 70) { +// return false +// } +// +// ++this.TotalChunks +// this.Address = 0 +// this.Address = a3 +// this.Address += a2 * 256 +// this.Address += a1 * 65536 +// } +// +// return true +// } +// +// @Throws(IOException::class) +// internal fun isaIPS(): Boolean { +// this.Buffer = ByteArray(5) +// this.PatchFile.read(this.Buffer) +// return this.Buffer[0].toInt() == 80 && this.Buffer[1].toInt() == 65 && this.Buffer[2].toInt() == 84 && this.Buffer[3].toInt() == 67 && this.Buffer[4].toInt() == 72 +// } +// +// @Throws(IOException::class) +// internal fun GetChunk() { +// this.Buffer = ByteArray(this.NumBytes) +// this.PatchFile.read(this.Buffer) +// } +// +// @Throws(IOException::class) +// internal fun ApplyPatch() { +// this.OrigFile.seek(this.Address.toLong()) +// this.OrigFile.write(this.Buffer, 0, this.NumBytes) +// } +// +// @Throws(IOException::class) +// internal fun ApplyRLE() { +// this.OrigFile.seek(this.Address.toLong()) +// +// for (i in 0 until this.NumBytes) { +// this.OrigFile.write(this.RLEByte.toInt()) +// } +// +// } +// +// @Throws(IOException::class) +// internal fun GetRLE() { +// val r1 = this.PatchFile.readUnsignedByte() +// val r2 = this.PatchFile.readUnsignedByte() +// val rb = this.PatchFile.readUnsignedByte() +// this.RLEBytes = r2 +// this.RLEBytes += r1 * 256 +// this.RLEByte = rb.toChar() +// } +// +// fun patch() { +// try { +// if (this.isaIPS()) { +// if (this.log) { +// this.LogFile.writeBytes("JIPS 3.0 Logfile\nTo have news about JIPS and other ZeroSoft Projects\nvisit: http://zerosoft.zophar.net\n\n") +// } +// +// while (this.GetAddress()) { +// this.GetNumBytes() +// if (this.NumBytes != 0) { +// this.GetChunk() +// } +// +// if (this.NumBytes != 0) { +// this.ApplyPatch() +// if (this.log) { +// this.LogFile.writeBytes("Chunk number: " + Integer.toString(this.TotalChunks) + " Offset: " + Integer.toHexString(this.Address) + " Bytes: " + Integer.toHexString(this.NumBytes) + "\n") +// } +// } else { +// this.ApplyRLE() +// if (this.log) { +// this.LogFile.writeBytes("Chunk number: " + Integer.toString(this.TotalChunks) + " Offset: " + Integer.toHexString(this.Address) + " Bytes: " + Integer.toHexString(this.NumBytes) + " RLE char: " + Integer.toHexString(this.RLEByte.toInt()) + " Lenght: " + Integer.toString(this.RLEBytes) + "\n") +// } +// } +// } +// +// JOptionPane.showMessageDialog(this.parent, "Patching Complete!\nPatches applied: " + this.TotalChunks) +// } +// } catch (var2: IOException) { +// JOptionPane.showMessageDialog(this.parent, "An error occurred during patching:\n" + var2.message) +// } +// +// } +// +// companion object { +// internal var IPSE_Patch = 1 +// internal var IPSE_File = 2 +// } +//}