Compare commits
4 Commits
37c489f252
...
6f943ae8c2
Author | SHA1 | Date |
---|---|---|
Denis Molony | 6f943ae8c2 | |
Denis Molony | 5add6c0729 | |
Denis Molony | 921c946ab5 | |
Denis Molony | 898587b23b |
|
@ -88,7 +88,7 @@ public class CPMDisk extends AbstractFormattedDisk
|
||||||
if (b1 > 31 && b1 != EMPTY_BYTE_VALUE)
|
if (b1 > 31 && b1 != EMPTY_BYTE_VALUE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (b2 < 32 || (b2 > 126 && b2 != EMPTY_BYTE_VALUE))
|
if (b2 <= 32 || (b2 > 126 && b2 != EMPTY_BYTE_VALUE))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for (int i = 0; i < buffer.length; i += 32)
|
for (int i = 0; i < buffer.length; i += 32)
|
||||||
|
@ -99,7 +99,7 @@ public class CPMDisk extends AbstractFormattedDisk
|
||||||
if (b1 == EMPTY_BYTE_VALUE) // deleted file??
|
if (b1 == EMPTY_BYTE_VALUE) // deleted file??
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (b2 < 32 || (b2 > 126 && b2 != EMPTY_BYTE_VALUE))
|
if (b2 <= 32 || (b2 > 126 && b2 != EMPTY_BYTE_VALUE))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
DirectoryEntry entry = new DirectoryEntry (this, buffer, i);
|
DirectoryEntry entry = new DirectoryEntry (this, buffer, i);
|
||||||
|
@ -188,9 +188,8 @@ public class CPMDisk extends AbstractFormattedDisk
|
||||||
public AppleFileSource getCatalog ()
|
public AppleFileSource getCatalog ()
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String line =
|
String line = "---- --------- --- - - -- -- -- -- ----------------------------"
|
||||||
"---- --------- --- - - -- -- -- -- ----------------------------"
|
+ "-------------------\n";
|
||||||
+ "-------------------\n";
|
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
text.append (String.format ("File : %s%n%n", getDisplayPath ()));
|
text.append (String.format ("File : %s%n%n", getDisplayPath ()));
|
||||||
text.append ("User Name Typ R S Ex S2 S1 RC Blocks\n");
|
text.append ("User Name Typ R S Ex S2 S1 RC Blocks\n");
|
||||||
|
|
|
@ -139,9 +139,8 @@ class DirectoryEntry implements AppleFileSource
|
||||||
char ro = readOnly ? '*' : ' ';
|
char ro = readOnly ? '*' : ' ';
|
||||||
char sf = systemFile ? '*' : ' ';
|
char sf = systemFile ? '*' : ' ';
|
||||||
|
|
||||||
String text =
|
String text = String.format ("%3d %-8s %-3s %s %s %02X %02X %02X %02X %s",
|
||||||
String.format ("%3d %-8s %-3s %s %s %02X %02X %02X %02X %s",
|
userNumber, name, type, ro, sf, extent, s2, s1, recordsUsed, bytes);
|
||||||
userNumber, name, type, ro, sf, extent, s2, s1, recordsUsed, bytes);
|
|
||||||
for (DirectoryEntry entry : entries)
|
for (DirectoryEntry entry : entries)
|
||||||
text = text + "\n" + entry.line ();
|
text = text + "\n" + entry.line ();
|
||||||
|
|
||||||
|
@ -218,14 +217,13 @@ class DirectoryEntry implements AppleFileSource
|
||||||
else if ("DVR".equals (type))
|
else if ("DVR".equals (type))
|
||||||
appleFile = new DefaultAppleFile (name, exactBuffer, "DVR File");
|
appleFile = new DefaultAppleFile (name, exactBuffer, "DVR File");
|
||||||
else if ("ASM".equals (type) || "DOC".equals (type) || "COB".equals (type)
|
else if ("ASM".equals (type) || "DOC".equals (type) || "COB".equals (type)
|
||||||
|| "HLP".equals (type) || "TXT".equals (type) || "LET".equals (type)
|
|| "HLP".equals (type) || "TXT".equals (type) || "LET".equals (type) || "ALX".equals (type)
|
||||||
|| "ALX".equals (type) || "SRC".equals (type) || "H".equals (type)
|
|| "SRC".equals (type) || "H".equals (type) || exactBuffer[len - 1] == 0x1A)
|
||||||
|| exactBuffer[len - 1] == 0x1A)
|
|
||||||
appleFile = new CPMTextFile (name, exactBuffer);
|
appleFile = new CPMTextFile (name, exactBuffer);
|
||||||
else if ("BAS".equals (type))
|
else if ("BAS".equals (type))
|
||||||
appleFile = new CPMBasicFile (name, exactBuffer);
|
appleFile = new CPMBasicFile (name, exactBuffer);
|
||||||
else
|
else
|
||||||
appleFile = new DefaultAppleFile (name, exactBuffer, "CPM File : " + type);
|
appleFile = new DefaultAppleFile (name, exactBuffer, "CPM File : " + name + "." + type);
|
||||||
|
|
||||||
return appleFile;
|
return appleFile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ public class DiskFactory
|
||||||
|
|
||||||
if ("sdk".equals (suffix) // NuFX disk
|
if ("sdk".equals (suffix) // NuFX disk
|
||||||
|| "shk".equals (suffix) // NuFX files or disk
|
|| "shk".equals (suffix) // NuFX files or disk
|
||||||
|| "bxy".equals (suffix)) // NuFX in Binary2
|
|| "bxy".equals (suffix)) // NuFX in Bin2
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
System.out.println (" ** sdk/shk/bxy **");
|
System.out.println (" ** sdk/shk/bxy **");
|
||||||
|
@ -156,7 +156,11 @@ public class DiskFactory
|
||||||
{
|
{
|
||||||
nuFX = new NuFX (file.toPath ());
|
nuFX = new NuFX (file.toPath ());
|
||||||
if (nuFX.getTotalDisks () == 0 && nuFX.getTotalFiles () == 0)
|
if (nuFX.getTotalDisks () == 0 && nuFX.getTotalFiles () == 0)
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
System.out.println ("Empty NuFX file");
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
byte[] diskBuffer = nuFX.getDiskBuffer ();
|
byte[] diskBuffer = nuFX.getDiskBuffer ();
|
||||||
if (diskBuffer == null)
|
if (diskBuffer == null)
|
||||||
|
@ -183,10 +187,10 @@ public class DiskFactory
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ("bny".equals (suffix)) // Binary2 uncompressed files
|
else if ("bny".equals (suffix) || "bqy".equals (suffix)) // Binary2 uncompressed files
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
System.out.println (" ** bny **");
|
System.out.println (" ** bny/bqy **");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
binary2 = new Binary2 (file.toPath ());
|
binary2 = new Binary2 (file.toPath ());
|
||||||
|
|
|
@ -15,27 +15,21 @@ import com.bytezone.diskbrowser.utilities.DefaultAction;
|
||||||
public abstract class AbstractSaveAction extends DefaultAction
|
public abstract class AbstractSaveAction extends DefaultAction
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private JFileChooser fileChooser;
|
protected JFileChooser fileChooser = new JFileChooser ();
|
||||||
private String dialogTitle;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public AbstractSaveAction (String menuText, String tip, String dialogTitle)
|
public AbstractSaveAction (String menuText, String tip, String dialogTitle)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (menuText, tip);
|
super (menuText, tip);
|
||||||
this.dialogTitle = dialogTitle;
|
|
||||||
|
fileChooser.setDialogTitle (dialogTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
void setSelectedFile (File file)
|
void setSelectedFile (File file)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (fileChooser == null)
|
|
||||||
{
|
|
||||||
fileChooser = new JFileChooser ();
|
|
||||||
fileChooser.setDialogTitle (dialogTitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
fileChooser.setSelectedFile (file);
|
fileChooser.setSelectedFile (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,26 +37,22 @@ public abstract class AbstractSaveAction extends DefaultAction
|
||||||
void saveBuffer (byte[] buffer)
|
void saveBuffer (byte[] buffer)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (fileChooser.showSaveDialog (null) != JFileChooser.APPROVE_OPTION)
|
|
||||||
return;
|
|
||||||
|
|
||||||
File file = fileChooser.getSelectedFile ();
|
File file = fileChooser.getSelectedFile ();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Files.write (file.toPath (), buffer, StandardOpenOption.CREATE_NEW);
|
Files.write (file.toPath (), buffer, StandardOpenOption.CREATE_NEW);
|
||||||
JOptionPane.showMessageDialog (null,
|
JOptionPane.showMessageDialog (null, String.format ("File %s saved", file.getName ()));
|
||||||
String.format ("File %s saved", file.getName ()));
|
|
||||||
}
|
}
|
||||||
catch (FileAlreadyExistsException e)
|
catch (FileAlreadyExistsException e)
|
||||||
{
|
{
|
||||||
JOptionPane.showMessageDialog (null, "File " + file.getName () + " already exists",
|
JOptionPane.showMessageDialog (null, "File " + file.getName () + " already exists", "Failed",
|
||||||
"Failed", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace ();
|
e.printStackTrace ();
|
||||||
JOptionPane.showMessageDialog (null, "File failed to save - " + e.getMessage (),
|
JOptionPane.showMessageDialog (null, "File failed to save - " + e.getMessage (), "Failed",
|
||||||
"Failed", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class FontAction extends DefaultAction implements QuitListener
|
||||||
{
|
{
|
||||||
super ("Set Font...", "Set display to a different font or font size",
|
super ("Set Font...", "Set display to a different font or font size",
|
||||||
"/com/bytezone/loadlister/");
|
"/com/bytezone/loadlister/");
|
||||||
|
|
||||||
int mask = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMaskEx ();
|
int mask = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMaskEx ();
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_F, mask));
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_F, mask));
|
||||||
}
|
}
|
||||||
|
@ -146,8 +147,7 @@ public class FontAction extends DefaultAction implements QuitListener
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
FontChangeEvent fontChangeEvent = new FontChangeEvent (font);
|
FontChangeEvent fontChangeEvent = new FontChangeEvent (font);
|
||||||
FontChangeListener[] listeners =
|
FontChangeListener[] listeners = (listenerList.getListeners (FontChangeListener.class));
|
||||||
(listenerList.getListeners (FontChangeListener.class));
|
|
||||||
for (FontChangeListener listener : listeners)
|
for (FontChangeListener listener : listeners)
|
||||||
listener.changeFont (fontChangeEvent);
|
listener.changeFont (fontChangeEvent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.bytezone.diskbrowser.gui;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.disk.AppleDisk;
|
import com.bytezone.diskbrowser.disk.AppleDisk;
|
||||||
|
@ -40,7 +41,9 @@ class SaveDiskAction extends AbstractSaveAction implements DiskSelectionListener
|
||||||
String suffix = blocks <= 560 ? ".dsk" : ".hdv";
|
String suffix = blocks <= 560 ? ".dsk" : ".hdv";
|
||||||
|
|
||||||
setSelectedFile (new File (formattedDisk.getName () + suffix));
|
setSelectedFile (new File (formattedDisk.getName () + suffix));
|
||||||
saveBuffer (appleDisk.getBuffer ());
|
|
||||||
|
if (fileChooser.showSaveDialog (null) == JFileChooser.APPROVE_OPTION)
|
||||||
|
saveBuffer (appleDisk.getBuffer ());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
System.out.println ("Not an AppleDisk"); // impossible
|
System.out.println ("Not an AppleDisk"); // impossible
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import javax.swing.Action;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.KeyStroke;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||||
|
|
||||||
|
@ -12,12 +18,17 @@ class SaveFileAction extends AbstractSaveAction implements FileSelectionListener
|
||||||
//-----------------------------------------------------------------------------------//
|
//-----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
AppleFileSource appleFileSource;
|
AppleFileSource appleFileSource;
|
||||||
|
private JCheckBox formatted = new JCheckBox ("Formatted");
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
SaveFileAction ()
|
SaveFileAction ()
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("Save file...", "Save currently selected file", "Save File");
|
super ("Save file...", "Save currently selected file", "Save File");
|
||||||
|
|
||||||
|
fileChooser.setAccessory (formatted);
|
||||||
|
int mask = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMaskEx ();
|
||||||
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_S, mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -31,8 +42,18 @@ class SaveFileAction extends AbstractSaveAction implements FileSelectionListener
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSelectedFile (new File (appleFileSource.getUniqueName () + ".bin"));
|
if (formatted.isSelected ())
|
||||||
saveBuffer (appleFileSource.getDataSource ().getBuffer ());
|
setSelectedFile (new File (appleFileSource.getUniqueName () + ".txt"));
|
||||||
|
else
|
||||||
|
setSelectedFile (new File (appleFileSource.getUniqueName () + ".bin"));
|
||||||
|
|
||||||
|
if (fileChooser.showSaveDialog (null) != JFileChooser.APPROVE_OPTION)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (formatted.isSelected ())
|
||||||
|
saveBuffer (appleFileSource.getDataSource ().getText ().getBytes ());
|
||||||
|
else
|
||||||
|
saveBuffer (appleFileSource.getDataSource ().getBuffer ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -41,8 +62,8 @@ class SaveFileAction extends AbstractSaveAction implements FileSelectionListener
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.appleFileSource = event.appleFileSource;
|
this.appleFileSource = event.appleFileSource;
|
||||||
setEnabled (
|
|
||||||
event.appleFileSource != null && event.appleFileSource.getDataSource () != null
|
setEnabled (appleFileSource != null && appleFileSource.getDataSource () != null
|
||||||
&& event.appleFileSource.getDataSource ().getBuffer () != null);
|
&& appleFileSource.getDataSource ().getBuffer () != null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.awt.event.ActionEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.disk.Disk;
|
import com.bytezone.diskbrowser.disk.Disk;
|
||||||
|
@ -41,7 +42,9 @@ class SaveSectorsAction extends AbstractSaveAction implements SectorSelectionLis
|
||||||
blocks.size () == 1 ? disk.readBlock (blocks.get (0)) : disk.readBlocks (blocks);
|
blocks.size () == 1 ? disk.readBlock (blocks.get (0)) : disk.readBlocks (blocks);
|
||||||
|
|
||||||
setSelectedFile (new File ("SavedSectors.bin"));
|
setSelectedFile (new File ("SavedSectors.bin"));
|
||||||
saveBuffer (buffer);
|
|
||||||
|
if (fileChooser.showSaveDialog (null) == JFileChooser.APPROVE_OPTION)
|
||||||
|
saveBuffer (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
|
@ -10,20 +10,20 @@ import com.bytezone.diskbrowser.prodos.write.DiskFullException;
|
||||||
import com.bytezone.diskbrowser.prodos.write.FileAlreadyExistsException;
|
import com.bytezone.diskbrowser.prodos.write.FileAlreadyExistsException;
|
||||||
import com.bytezone.diskbrowser.prodos.write.ProdosDisk;
|
import com.bytezone.diskbrowser.prodos.write.ProdosDisk;
|
||||||
import com.bytezone.diskbrowser.prodos.write.VolumeCatalogFullException;
|
import com.bytezone.diskbrowser.prodos.write.VolumeCatalogFullException;
|
||||||
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
public class Binary2
|
public class Binary2
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final String UNDERLINE =
|
private static final String UNDERLINE =
|
||||||
"------------------------------------------------------"
|
"------------------------------------------------------" + "-----------------------";
|
||||||
+ "-----------------------";
|
|
||||||
|
|
||||||
Binary2Header binary2Header;
|
private Binary2Header binary2Header;
|
||||||
byte[] buffer;
|
private byte[] buffer;
|
||||||
List<Binary2Header> headers = new ArrayList<> ();
|
private List<Binary2Header> headers = new ArrayList<> ();
|
||||||
int totalBlocks;
|
private int totalBlocks;
|
||||||
String fileName;
|
private String fileName;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public Binary2 (Path path) throws IOException
|
public Binary2 (Path path) throws IOException
|
||||||
|
@ -43,18 +43,17 @@ public class Binary2
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
binary2Header = new Binary2Header (buffer, ptr);
|
binary2Header = new Binary2Header (buffer, ptr);
|
||||||
System.out.println (binary2Header);
|
|
||||||
headers.add (binary2Header);
|
headers.add (binary2Header);
|
||||||
|
|
||||||
totalBlocks += binary2Header.totalBlocks;
|
totalBlocks += binary2Header.totalBlocks;
|
||||||
ptr += ((binary2Header.eof - 1) / 128 + 1) * 128 + 128;
|
ptr += ((binary2Header.eof - 1) / 128 + 2) * 128;
|
||||||
} while (binary2Header.filesToFollow > 0);
|
} while (binary2Header.filesToFollow > 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public byte[] getDiskBuffer () throws DiskFullException, VolumeCatalogFullException,
|
public byte[] getDiskBuffer ()
|
||||||
FileAlreadyExistsException, IOException
|
throws DiskFullException, VolumeCatalogFullException, FileAlreadyExistsException, IOException
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
ProdosDisk disk = new ProdosDisk (800, "DiskBrowser");
|
ProdosDisk disk = new ProdosDisk (800, "DiskBrowser");
|
||||||
|
@ -64,9 +63,19 @@ public class Binary2
|
||||||
byte[] dataBuffer = new byte[header.eof]; // this sux
|
byte[] dataBuffer = new byte[header.eof]; // this sux
|
||||||
System.arraycopy (buffer, header.ptr + 128, dataBuffer, 0, dataBuffer.length);
|
System.arraycopy (buffer, header.ptr + 128, dataBuffer, 0, dataBuffer.length);
|
||||||
|
|
||||||
disk.addFile (header.fileName, header.fileType, header.auxType, header.created,
|
if (header.compressed && dataBuffer[0] == 0x76 && dataBuffer[1] == (byte) 0xFF)
|
||||||
header.modified, dataBuffer, header.eof);
|
{
|
||||||
|
String name = Utility.getCString (dataBuffer, 4);
|
||||||
|
|
||||||
|
Squeeze squeeze = new Squeeze ();
|
||||||
|
byte[] tmp = squeeze.unSqueeze (dataBuffer);
|
||||||
|
|
||||||
|
disk.addFile (name, header.fileType, header.auxType, header.created, header.modified, tmp,
|
||||||
|
tmp.length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
disk.addFile (header.fileName, header.fileType, header.auxType, header.created,
|
||||||
|
header.modified, dataBuffer, header.eof);
|
||||||
}
|
}
|
||||||
disk.close ();
|
disk.close ();
|
||||||
|
|
||||||
|
@ -80,12 +89,12 @@ public class Binary2
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
text.append (String.format (
|
text.append (
|
||||||
" %-15.15s Files:%5d%n%n",
|
String.format (" %-15.15s Files:%5d%n%n",
|
||||||
fileName, headers.size ()));
|
fileName, headers.size ()));
|
||||||
|
|
||||||
text.append (" Name Type Auxtyp Modified"
|
text.append (
|
||||||
+ " Fmat Length\n");
|
" Name Type Auxtyp Modified" + " Fmat Length\n");
|
||||||
|
|
||||||
text.append (String.format ("%s%n", UNDERLINE));
|
text.append (String.format ("%s%n", UNDERLINE));
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,9 @@ public class Binary2Header
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
static DateTimeFormatter formatter = DateTimeFormatter.ofPattern ("dd-LLL-yy HH:mm");
|
static DateTimeFormatter formatter = DateTimeFormatter.ofPattern ("dd-LLL-yy HH:mm");
|
||||||
static String[] osTypes =
|
static String[] osTypes = { "Prodos", "DOS 3.3", "Reserved", "DOS 3.2 or 3.1", "Pascal",
|
||||||
{ "Prodos", "DOS 3.3", "Reserved", "DOS 3.2 or 3.1", "Pascal", "Macintosh MFS",
|
"Macintosh MFS", "Macintosh HFS", "Lisa", "CPM", "Reserved", "MS-DOS", "High Sierra (CD-ROM)",
|
||||||
"Macintosh HFS", "Lisa", "CPM", "Reserved", "MS-DOS", "High Sierra (CD-ROM)",
|
"ISO 9660 (CD-ROM)", "AppleShare" };
|
||||||
"ISO 9660 (CD-ROM)", "AppleShare" };
|
|
||||||
|
|
||||||
int ptr;
|
int ptr;
|
||||||
byte[] buffer;
|
byte[] buffer;
|
||||||
|
@ -89,8 +88,8 @@ public class Binary2Header
|
||||||
public String getLine ()
|
public String getLine ()
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return String.format (" %-33s %3s $%04X %s unc %7d", fileName,
|
return String.format (" %-33s %3s $%04X %s unc %7d", fileName, fileTypes[fileType],
|
||||||
fileTypes[fileType], auxType, modified.format (formatter), eof);
|
auxType, modified.format (formatter), eof);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -117,12 +116,13 @@ public class Binary2Header
|
||||||
text.append (String.format ("Prodos storage type ... %02X%n", prodos16storageType));
|
text.append (String.format ("Prodos storage type ... %02X%n", prodos16storageType));
|
||||||
text.append (String.format ("Prodos total blocks ... %02X%n", prodos16totalBlocks));
|
text.append (String.format ("Prodos total blocks ... %02X%n", prodos16totalBlocks));
|
||||||
text.append (String.format ("Prodos eof ............ %06X %<,d%n", prodos16eof));
|
text.append (String.format ("Prodos eof ............ %06X %<,d%n", prodos16eof));
|
||||||
text.append (
|
text.append (String.format ("Disk space needed ..... %08X %<,d%n", diskSpaceRequired));
|
||||||
String.format ("Disk space needed ..... %08X %<,d%n", diskSpaceRequired));
|
text.append (String.format ("OS type ............... %02X %s%n", osType, osTypes[osType]));
|
||||||
text.append (
|
|
||||||
String.format ("OS type ............... %02X %s%n", osType, osTypes[osType]));
|
|
||||||
text.append (String.format ("Native file type ...... %02X%n", nativeFileType));
|
text.append (String.format ("Native file type ...... %02X%n", nativeFileType));
|
||||||
text.append (String.format ("Data flags ............ %02X%n", dataFlags));
|
text.append (String.format ("Data flags ............ %02X%n", dataFlags));
|
||||||
|
text.append (String.format (" compressed .......... %s%n", compressed));
|
||||||
|
text.append (String.format (" encrypted ........... %s%n", encrypted));
|
||||||
|
text.append (String.format (" sparse .............. %s%n", sparsePacked));
|
||||||
text.append (String.format ("Version ............... %02X%n", version));
|
text.append (String.format ("Version ............... %02X%n", version));
|
||||||
text.append (String.format ("Following files ....... %02X%n", filesToFollow));
|
text.append (String.format ("Following files ....... %02X%n", filesToFollow));
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,125 @@
|
||||||
|
package com.bytezone.diskbrowser.nufx;
|
||||||
|
|
||||||
|
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
||||||
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
|
|
||||||
|
// see http://fileformats.archiveteam.org/wiki/Squeeze
|
||||||
|
// see http://fileformats.archiveteam.org/wiki/RLE90
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
|
public class Squeeze
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
private static final byte[] Squeeze = { 0x76, (byte) 0xFF };
|
||||||
|
private static int RLE_DELIMITER = 0x90;
|
||||||
|
private static int EOF_TOKEN = 0x100;
|
||||||
|
|
||||||
|
private int bits;
|
||||||
|
private int bitPos = 7; // trigger the first read
|
||||||
|
private int ptr;
|
||||||
|
private byte[] buffer;
|
||||||
|
private Node[] nodes;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public byte[] unSqueeze (byte[] buffer)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
if (!Utility.isMagic (buffer, 0, Squeeze))
|
||||||
|
throw new FileFormatException ("Not Squeeze format");
|
||||||
|
|
||||||
|
byte[] uncompressed = new byte[buffer.length * 3];
|
||||||
|
int uncPtr = 0;
|
||||||
|
|
||||||
|
int fileChecksum = Utility.getShort (buffer, 2);
|
||||||
|
String fileName = Utility.getCString (buffer, 4);
|
||||||
|
|
||||||
|
ptr = fileName.length () + 5;
|
||||||
|
int nodeCount = Utility.getShort (buffer, ptr);
|
||||||
|
ptr += 2;
|
||||||
|
|
||||||
|
nodes = new Node[nodeCount];
|
||||||
|
this.buffer = buffer;
|
||||||
|
|
||||||
|
for (int i = 0; i < nodes.length; i++)
|
||||||
|
{
|
||||||
|
int left = Utility.getSignedShort (buffer, ptr);
|
||||||
|
int right = Utility.getSignedShort (buffer, ptr + 2);
|
||||||
|
nodes[i] = new Node (left, right);
|
||||||
|
ptr += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean repeating = false;
|
||||||
|
int lastVal = 0;
|
||||||
|
int sum = 0;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
int val = decodeSymbol ();
|
||||||
|
if (val == EOF_TOKEN)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (repeating)
|
||||||
|
{
|
||||||
|
repeating = false;
|
||||||
|
|
||||||
|
if (val == 0) // flag indicating a single RLE_DELIMITER
|
||||||
|
{
|
||||||
|
lastVal = RLE_DELIMITER;
|
||||||
|
val = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (--val != 0)
|
||||||
|
{
|
||||||
|
sum += lastVal;
|
||||||
|
uncompressed[uncPtr++] = (byte) lastVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (val == RLE_DELIMITER)
|
||||||
|
repeating = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lastVal = val;
|
||||||
|
sum += lastVal;
|
||||||
|
uncompressed[uncPtr++] = (byte) lastVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((sum & 0xFFFF) != fileChecksum)
|
||||||
|
System.out.printf ("Checksum mismatch : %04X %04X%n", fileChecksum, sum & 0xFFFF);
|
||||||
|
|
||||||
|
byte[] uncompressedBuffer = new byte[uncPtr];
|
||||||
|
System.arraycopy (uncompressed, 0, uncompressedBuffer, 0, uncompressedBuffer.length);
|
||||||
|
|
||||||
|
return uncompressedBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
private int decodeSymbol ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
int val = 0;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (++bitPos > 7)
|
||||||
|
{
|
||||||
|
bits = buffer[ptr++];
|
||||||
|
bitPos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
val = (bits & 1) == 0 ? nodes[val].left : nodes[val].right;
|
||||||
|
bits >>>= 1;
|
||||||
|
|
||||||
|
if (val < 0)
|
||||||
|
return -++val; // increment and make positive
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
record Node (int left, int right)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package com.bytezone.diskbrowser.pascal;
|
package com.bytezone.diskbrowser.pascal;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.FormatStyle;
|
import java.time.format.FormatStyle;
|
||||||
|
@ -30,7 +29,6 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
static final int CATALOG_ENTRY_SIZE = 26;
|
static final int CATALOG_ENTRY_SIZE = 26;
|
||||||
private final DateFormat df = DateFormat.getDateInstance (DateFormat.SHORT);
|
|
||||||
private final DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT);
|
private final DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT);
|
||||||
private final VolumeEntry volumeEntry;
|
private final VolumeEntry volumeEntry;
|
||||||
private final PascalCatalogSector diskCatalogSector;
|
private final PascalCatalogSector diskCatalogSector;
|
||||||
|
@ -235,7 +233,6 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||||
}
|
}
|
||||||
|
|
||||||
int lastByte = Utility.getShort (buffer, ptr + 22);
|
int lastByte = Utility.getShort (buffer, ptr + 22);
|
||||||
// GregorianCalendar date = Utility.getPascalDate (buffer, 24);
|
|
||||||
LocalDate localDate = Utility.getPascalLocalDate (buffer, 24);
|
LocalDate localDate = Utility.getPascalLocalDate (buffer, 24);
|
||||||
String dateString = localDate == null ? ""
|
String dateString = localDate == null ? ""
|
||||||
: localDate.format (DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT));
|
: localDate.format (DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT));
|
||||||
|
|
|
@ -17,6 +17,7 @@ public abstract class DefaultAction extends AbstractAction
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (text);
|
super (text);
|
||||||
|
|
||||||
this.baseURL = null;
|
this.baseURL = null;
|
||||||
putValue (Action.SHORT_DESCRIPTION, tip);
|
putValue (Action.SHORT_DESCRIPTION, tip);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +27,7 @@ public abstract class DefaultAction extends AbstractAction
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (text);
|
super (text);
|
||||||
|
|
||||||
this.baseURL = baseURL;
|
this.baseURL = baseURL;
|
||||||
putValue (Action.SHORT_DESCRIPTION, tip);
|
putValue (Action.SHORT_DESCRIPTION, tip);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +41,7 @@ public abstract class DefaultAction extends AbstractAction
|
||||||
System.out.println ("Base URL not set");
|
System.out.println ("Base URL not set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
URL url = this.getClass ().getResource (baseURL + iconName);
|
URL url = this.getClass ().getResource (baseURL + iconName);
|
||||||
if (url != null)
|
if (url != null)
|
||||||
putValue (iconType, new ImageIcon (url));
|
putValue (iconType, new ImageIcon (url));
|
||||||
|
|
|
@ -41,7 +41,7 @@ public final class Utility
|
||||||
private static MathContext mathContext8 = new MathContext (15);
|
private static MathContext mathContext8 = new MathContext (15);
|
||||||
|
|
||||||
private static final List<String> suffixes = Arrays.asList ("po", "dsk", "do", "hdv", "2mg",
|
private static final List<String> suffixes = Arrays.asList ("po", "dsk", "do", "hdv", "2mg",
|
||||||
"d13", "sdk", "shk", "bxy", "bny", "woz", "img", "dimg");
|
"d13", "sdk", "shk", "bxy", "bny", "bqy", "woz", "img", "dimg");
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
private Utility ()
|
private Utility ()
|
||||||
|
@ -454,6 +454,19 @@ public final class Utility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public static String getCString (byte[] buffer, int offset)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
int length = 0;
|
||||||
|
int ptr = offset;
|
||||||
|
|
||||||
|
while (buffer[ptr++] != 0)
|
||||||
|
++length;
|
||||||
|
|
||||||
|
return new String (buffer, offset, length);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public static int getWizLong (byte[] buffer, int offset)
|
public static int getWizLong (byte[] buffer, int offset)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
Loading…
Reference in New Issue