This commit is contained in:
Denis Molony 2016-12-15 22:21:50 +11:00
parent fc9d408f35
commit 4c0494410e
8 changed files with 18 additions and 110 deletions

View File

@ -172,13 +172,21 @@ public class CPMDisk extends AbstractFormattedDisk
for (int sector = 0; sector < 8; sector++)
{
byte[] buffer = disk.readSector (3, sector);
// check if entire sector is empty (everything == 0xE5)
if (bufferContainsAll (buffer, (byte) 0xE5))
break;
// System.out.println (HexFormatter.format (buffer));
for (int i = 0; i < buffer.length; i += 32)
{
int val = buffer[i] & 0xFF;
// System.out.printf ("%02X%n", val);
// if (val == 0xE5)
// return true;
// break;
if (val > 31 && val != 0xE5)
return false;
for (int j = 1; j <= 8; j++)
{
val = buffer[i + j] & 0xFF;
@ -190,4 +198,12 @@ public class CPMDisk extends AbstractFormattedDisk
return true;
}
private static boolean bufferContainsAll (byte[] buffer, byte value)
{
for (byte b : buffer)
if (b != value)
return false;
return true;
}
}

View File

@ -66,7 +66,6 @@ public class RootFolderData
dialogTotals.setTitle ("Disk Totals");
dialogTotals.pack ();
dialogTotals.setLocationRelativeTo (null);
// btnCancel.requestFocus ();
btnCancel.addActionListener (new ActionListener ()
{

View File

@ -59,17 +59,8 @@ class CatalogPanel extends JTabbedPane
public CatalogPanel (MenuHandler mh, RedoHandler redoHandler, Preferences prefs)
{
// String catalogFontName =
// prefs.get (PreferencesDialog.prefsCatalogFont, PreferencesDialog.defaultFontName);
// int catalogFontSize =
// prefs.getInt (PreferencesDialog.prefsCatalogFontSize,
// PreferencesDialog.defaultFontSize);
// this.font = new Font (catalogFontName, Font.PLAIN, catalogFontSize);
// this.lister = new DocumentCreatorFactory (mh);
this.redoHandler = redoHandler;
// selector.addDiskSelectionListener (lister.diskLister);
setTabPlacement (SwingConstants.BOTTOM);
setPreferredSize (new Dimension (360, 802)); // width, height
@ -177,7 +168,6 @@ class CatalogPanel extends JTabbedPane
fileTab = new FileSystemTab (rootFolderData.getRootFolder (), selector, redoHandler,
font, diskEvent);
fileTab.addTreeMouseListener (new MouseListener ()); // listen for disk selection
// lister.catalogLister.setNode (fileTab.getRootNode ());
insertTab ("Disk Tree", null, fileTab, "Display Apple disks", 0);
}

View File

@ -22,7 +22,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
public DiskBrowser ()
{
super (windowTitle);
long start = System.currentTimeMillis ();
if (false)
{
@ -31,9 +30,7 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
}
JToolBar toolBar = new JToolBar ("Toolbar", JToolBar.HORIZONTAL);
System.out.printf ("0: %d%n", System.currentTimeMillis () - start);
MenuHandler menuHandler = new MenuHandler (prefs);
System.out.printf ("1: %d%n", System.currentTimeMillis () - start);
setJMenuBar (menuHandler.menuBar);
setLayout (new BorderLayout ());
@ -59,11 +56,9 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
// create actions
RootFolderData rootFolderData = catalogPanel.getRootFolderData ();
DuplicateAction duplicateAction = new DuplicateAction (rootFolderData);
// CountDisksAction countDisksAction = new CountDisksAction (rootFolderData);
RootDirectoryAction rootDirectoryAction = new RootDirectoryAction (rootFolderData);
rootDirectoryAction.addListener (catalogPanel);
rootDirectoryAction.addListener (duplicateAction);
// rootDirectoryAction.addListener (countDisksAction);
RefreshTreeAction refreshTreeAction = new RefreshTreeAction (catalogPanel);
// PreferencesAction preferencesAction = new PreferencesAction (this, prefs);
@ -75,7 +70,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
ShowFreeSectorsAction showFreeAction =
new ShowFreeSectorsAction (menuHandler, diskLayoutPanel);
CloseTabAction closeTabAction = new CloseTabAction (catalogPanel);
System.out.printf ("2: %d%n", System.currentTimeMillis () - start);
// add action buttons to toolbar
toolBar.add (rootDirectoryAction);
@ -124,7 +118,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
menuHandler.showFreeSectorsItem.setAction (showFreeAction);
menuHandler.duplicateItem.setAction (duplicateAction);
menuHandler.closeTabItem.setAction (closeTabAction);
System.out.printf ("3: %d%n", System.currentTimeMillis () - start);
final QuitAction quitAction = Platform.setQuit (this, prefs, menuHandler.fileMenu);
@ -137,7 +130,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
catalogPanel.setCloseTabAction (closeTabAction);
pack ();
System.out.printf ("4: %d%n", System.currentTimeMillis () - start);
// restore the menuHandler items before they are referenced
quitAction.restore ();
@ -150,7 +142,6 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
// activate the highest panel now that the listeners are ready
catalogPanel.activate ();
System.out.printf ("5: %d%n", System.currentTimeMillis () - start);
}
private JPanel addPanel (JComponent pane, String title, String location)

View File

@ -54,25 +54,6 @@ class FileSystemTab extends AbstractTab
navMan.diskSelected (diskEvent);
else
System.out.println ("No disk event");
// temporary code while I sort out the DOS checksum feature
// if (tb.dosMap.keySet ().size () > 0)
// {
// System.out.printf ("Unique DOSs : %4d%n", tb.dosMap.keySet ().size ());
// long lastKey = -1;
// int beginIndex = rootFolder.getAbsolutePath ().length ();
// for (Long key : tb.dosMap.keySet ())
// {
// if (key != lastKey)
// {
// lastKey = key;
// System.out.printf ("%,14d (%d)%n", key, tb.dosMap.get (key).size ());
// }
// for (File file : tb.dosMap.get (key))
// System.out.printf (" %s%n",
// file.getAbsolutePath ().substring (beginIndex));
// }
// }
}
public FileSystemTab (File folder, DiskAndFileSelector selector, RedoHandler navMan,

View File

@ -36,14 +36,10 @@ public class MenuHandler
JMenu helpMenu = new JMenu ("Help");
// File menu items
JMenuItem openItem = new JMenuItem ("Open disk...");
JMenuItem rootItem = new JMenuItem ("Set root folder...");
JMenuItem refreshTreeItem = new JMenuItem ("Refresh current tree");
JMenuItem executeDiskItem;
JMenuItem printItem = new JMenuItem ("Print output panel...");
// public final JMenuItem createCatalogFileItem = new JMenuItem ("Create catalog file...");
// public final JMenuItem createDiskFileItem = new JMenuItem ("Create disk file...");
// JMenuItem dbItem = new JMenuItem (new CreateDatabaseAction ());
JMenuItem closeTabItem = new JMenuItem ();
JMenuItem duplicateItem = new JMenuItem ();
FontAction fontAction;
@ -64,18 +60,13 @@ public class MenuHandler
JMenuItem colourQuirksItem = new JCheckBoxMenuItem ("Colour quirks");
JMenuItem monochromeItem = new JCheckBoxMenuItem ("Monochrome");
JMenuItem debuggingItem = new JCheckBoxMenuItem ("Debugging");
// JMenuItem retinaItem = new JCheckBoxMenuItem ("Retina display");
public MenuHandler (Preferences prefs)
{
long start = System.currentTimeMillis ();
menuBar.add (fileMenu);
menuBar.add (formatMenu);
menuBar.add (helpMenu);
if (false)
fileMenu.add (openItem);
fileMenu.add (rootItem);
fileMenu.addSeparator ();
fileMenu.add (refreshTreeItem);
@ -86,9 +77,7 @@ public class MenuHandler
fileMenu.addSeparator ();
fileMenu.add (closeTabItem);
System.out.printf ("MenuHandler 0: %d%n", System.currentTimeMillis () - start);
fontAction = new FontAction ();
System.out.printf ("MenuHandler 1: %d%n", System.currentTimeMillis () - start);
JMenuItem fontItem = new JMenuItem (fontAction);
fileMenu.add (fontItem);
fontAction.setSampleText ("120 FOR Z = 14 TO 24:\n" + " VTAB 5:\n" + " HTAB Z:\n"
@ -96,13 +85,6 @@ public class MenuHandler
+ " POKE 1,9:\n" + " CALL MU:\n" + " VTAB 5:\n" + " HTAB Z:\n"
+ " PRINT SPC(12):\n" + "NEXT :\n" + "VTAB 5:\n" + "HTAB 24:\n" + "PRINT AB$\n");
if (false)
{
// fileMenu.add (createCatalogFileItem);
// fileMenu.add (createDiskFileItem);
// fileMenu.add (dbItem);
}
fileMenu.add (duplicateItem);
formatMenu.add (lineWrapItem);
@ -127,7 +109,6 @@ public class MenuHandler
formatMenu.add (colourQuirksItem);
formatMenu.add (monochromeItem);
formatMenu.add (debuggingItem);
// formatMenu.add (retinaItem);
helpMenu.add (new JMenuItem (new EnvironmentAction ()));
@ -145,9 +126,6 @@ public class MenuHandler
interleaveGroup.add (interleave1Item);
interleaveGroup.add (interleave2Item);
interleaveGroup.add (interleave3Item);
// dbItem.setEnabled (false);
System.out.printf ("MenuHandler 2: %d%n", System.currentTimeMillis () - start);
}
void addHelpMenuAction (Action action, String functionName)

View File

@ -1,48 +0,0 @@
package com.bytezone.diskbrowser.gui;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.File;
import javax.swing.Action;
import javax.swing.JFileChooser;
import javax.swing.KeyStroke;
import javax.swing.filechooser.FileNameExtensionFilter;
import com.bytezone.common.DefaultAction;
import com.bytezone.diskbrowser.disk.DiskFactory;
// I don't think this is needed anymore
class OpenFileAction extends DefaultAction
{
// DiskBrowser owner;
CatalogPanel catalogPanel;
public OpenFileAction (DiskBrowser owner, CatalogPanel catalogPanel)
{
super ("Open disk...", "Opens a single disk image", "/com/bytezone/diskbrowser/icons/");
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("control O"));
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_O);
// this.owner = owner;
this.catalogPanel = catalogPanel;
setIcon (Action.SMALL_ICON, "Open16.gif");
}
public void actionPerformed (ActionEvent e)
{
JFileChooser chooser = new JFileChooser ("C:/");
chooser.setDialogTitle ("Select disk image");
FileNameExtensionFilter filter = new FileNameExtensionFilter ("DSK & PO Images", "dsk", "po");
chooser.setFileFilter (filter);
// if (owner.selectedDisk != null)
// chooser.setSelectedFile (owner.selectedDisk.getDisk ().getFile ());
int result = chooser.showOpenDialog (null);
if (result == JFileChooser.APPROVE_OPTION)
{
File file = chooser.getSelectedFile ();
if (file != null)
catalogPanel.addDiskPanel (DiskFactory.createDisk (file.getAbsolutePath ()), null, true);
}
}
}

View File

@ -10,6 +10,7 @@ import javax.swing.KeyStroke;
import com.bytezone.common.DefaultAction;
// not currently used
public class PreferencesAction extends DefaultAction
{
JFrame owner;