This commit is contained in:
Denis Molony 2016-02-28 16:41:10 +11:00
parent 174d604233
commit 445ec60318
5 changed files with 35 additions and 31 deletions

View File

@ -16,11 +16,12 @@ public class CPMDisk extends AbstractFormattedDisk
public final SectorType catalogSector = new SectorType ("Catalog", green); public final SectorType catalogSector = new SectorType ("Catalog", green);
public final SectorType prnSector = new SectorType ("PRN", Color.lightGray); public final SectorType prnSector = new SectorType ("PRN", Color.lightGray);
public final SectorType comSector = new SectorType ("COM", Color.red); public final SectorType comSector = new SectorType ("COM", Color.red);
public final SectorType dataSector = new SectorType ("Data", Color.blue); public final SectorType otherSector = new SectorType ("Other", Color.blue);
public final SectorType docSector = new SectorType ("DOC", Color.cyan); public final SectorType docSector = new SectorType ("DOC", Color.cyan);
public final SectorType basSector = new SectorType ("BAS", Color.gray); public final SectorType basSector = new SectorType ("BAS", Color.gray);
public final SectorType asmSector = new SectorType ("ASM", Color.orange); public final SectorType asmSector = new SectorType ("ASM", Color.orange);
public final SectorType ovrSector = new SectorType ("OVR", Color.magenta); public final SectorType ovrSector = new SectorType ("OVR", Color.magenta);
public final SectorType macSector = new SectorType ("Green", Color.green);
private int version; // http://www.seasip.info/Cpm/format22.html private int version; // http://www.seasip.info/Cpm/format22.html
@ -31,11 +32,12 @@ public class CPMDisk extends AbstractFormattedDisk
sectorTypesList.add (catalogSector); sectorTypesList.add (catalogSector);
sectorTypesList.add (prnSector); sectorTypesList.add (prnSector);
sectorTypesList.add (comSector); sectorTypesList.add (comSector);
sectorTypesList.add (dataSector);
sectorTypesList.add (basSector); sectorTypesList.add (basSector);
sectorTypesList.add (docSector); sectorTypesList.add (docSector);
sectorTypesList.add (asmSector); sectorTypesList.add (asmSector);
sectorTypesList.add (ovrSector); sectorTypesList.add (ovrSector);
sectorTypesList.add (macSector);
sectorTypesList.add (otherSector);
getDisk ().setEmptyByte ((byte) 0xE5); getDisk ().setEmptyByte ((byte) 0xE5);
setSectorTypes (); setSectorTypes ();
@ -99,8 +101,10 @@ public class CPMDisk extends AbstractFormattedDisk
return asmSector; return asmSector;
if ("OVR".equals (type)) if ("OVR".equals (type))
return ovrSector; return ovrSector;
if ("MAC".equals (type))
return macSector;
return dataSector; return otherSector;
} }
@Override @Override

View File

@ -44,7 +44,7 @@ public class DiskFactory
Boolean compressed = false; Boolean compressed = false;
Path p = Paths.get (path); Path p = Paths.get (path);
if (suffix.equalsIgnoreCase ("sdk")) if (suffix.equals ("sdk"))
{ {
try try
{ {
@ -68,7 +68,7 @@ public class DiskFactory
return null; return null;
} }
} }
else if (suffix.equalsIgnoreCase ("gz")) // will be .dsk.gz else if (suffix.equals ("gz")) // will be .dsk.gz
{ {
try try
{ {
@ -266,6 +266,7 @@ public class DiskFactory
{ {
if (debug) if (debug)
System.out.println ("Checking Prodos disk"); System.out.println ("Checking Prodos disk");
try try
{ {
AppleDisk disk = new AppleDisk (file, 35, 8); AppleDisk disk = new AppleDisk (file, 35, 8);

View File

@ -1,12 +1,6 @@
package com.bytezone.diskbrowser.gui; package com.bytezone.diskbrowser.gui;
import java.awt.Color; import java.awt.*;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -26,7 +20,8 @@ import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
class DiskLayoutImage extends JPanel implements Scrollable class DiskLayoutImage extends JPanel implements Scrollable
{ {
static final Cursor crosshairCursor = new Cursor (Cursor.CROSSHAIR_CURSOR); static final Cursor crosshairCursor = new Cursor (Cursor.CROSSHAIR_CURSOR);
FormattedDisk disk;
private FormattedDisk disk;
LayoutDetails layoutDetails; LayoutDetails layoutDetails;
private boolean showFreeSectors; private boolean showFreeSectors;
DiskLayoutSelection selectionHandler = new DiskLayoutSelection (); DiskLayoutSelection selectionHandler = new DiskLayoutSelection ();
@ -51,9 +46,6 @@ class DiskLayoutImage extends JPanel implements Scrollable
this.disk = disk; this.disk = disk;
layoutDetails = details; layoutDetails = details;
// System.out.println (details);
// new Exception ().printStackTrace ();
bw = layoutDetails.block.width; bw = layoutDetails.block.width;
bh = layoutDetails.block.height; bh = layoutDetails.block.height;
gw = layoutDetails.grid.width; gw = layoutDetails.grid.width;
@ -65,6 +57,11 @@ class DiskLayoutImage extends JPanel implements Scrollable
repaint (); repaint ();
} }
public FormattedDisk getDisk ()
{
return disk;
}
public void setShowFreeSectors (boolean showFree) public void setShowFreeSectors (boolean showFree)
{ {
showFreeSectors = showFree; showFreeSectors = showFree;
@ -97,15 +94,10 @@ class DiskLayoutImage extends JPanel implements Scrollable
Rectangle clipRect = g.getClipBounds (); Rectangle clipRect = g.getClipBounds ();
Point p1 = new Point (clipRect.x / bw * bw, clipRect.y / bh * bh); Point p1 = new Point (clipRect.x / bw * bw, clipRect.y / bh * bh);
Point p2 = Point p2 = new Point ((clipRect.x + clipRect.width - 1) / bw * bw,
new Point ((clipRect.x + clipRect.width - 1) / bw * bw, (clipRect.y (clipRect.y + clipRect.height - 1) / bh * bh);
+ clipRect.height - 1)
/ bh * bh);
// System.out.printf ("gw=%d, gh=%d, bw=%d, bh=%d%n", gw, gh, bw, bh);
// int totalBlocks = 0;
int maxBlock = gw * gh; int maxBlock = gw * gh;
// System.out.printf ("Max blocks: %d%n", maxBlock);
Disk d = disk.getDisk (); Disk d = disk.getDisk ();
List<DiskAddress> selectedBlocks = selectionHandler.getHighlights (); List<DiskAddress> selectedBlocks = selectionHandler.getHighlights ();
@ -123,7 +115,6 @@ class DiskLayoutImage extends JPanel implements Scrollable
boolean flag = showFreeSectors && disk.isSectorFree (da); boolean flag = showFreeSectors && disk.isSectorFree (da);
boolean selected = selectedBlocks.contains (da); boolean selected = selectedBlocks.contains (da);
drawBlock ((Graphics2D) g, blockNo, x, y, flag, selected); drawBlock ((Graphics2D) g, blockNo, x, y, flag, selected);
// totalBlocks++;
} }
} }
} }
@ -135,7 +126,6 @@ class DiskLayoutImage extends JPanel implements Scrollable
int offset = (bw - 4) / 2 + 1; int offset = (bw - 4) / 2 + 1;
Rectangle rect = new Rectangle (x, y, bw, bh); Rectangle rect = new Rectangle (x, y, bw, bh);
// System.out.printf ("Rect: %4d %4d %4d %4d%n", x, y, bw, bh);
// draw frame // draw frame
if (true) // this needs to draw the outside rectangle, and show less white space if (true) // this needs to draw the outside rectangle, and show less white space
@ -176,7 +166,7 @@ class DiskLayoutImage extends JPanel implements Scrollable
{ {
if (type.colour == Color.WHITE || type.colour == Color.YELLOW if (type.colour == Color.WHITE || type.colour == Color.YELLOW
|| type.colour == Color.PINK || type.colour == Color.CYAN || type.colour == Color.PINK || type.colour == Color.CYAN
|| type.colour == Color.ORANGE) || type.colour == Color.ORANGE || type.colour == Color.GREEN)
return Color.BLACK; return Color.BLACK;
return Color.WHITE; return Color.WHITE;
} }

View File

@ -3,7 +3,11 @@ package com.bytezone.diskbrowser.gui;
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS; import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS; import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
@ -22,8 +26,8 @@ import com.bytezone.diskbrowser.disk.FormattedDisk;
import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent; import com.bytezone.diskbrowser.gui.RedoHandler.RedoEvent;
import com.bytezone.diskbrowser.gui.RedoHandler.RedoListener; import com.bytezone.diskbrowser.gui.RedoHandler.RedoListener;
class DiskLayoutPanel extends JPanel implements DiskSelectionListener, FileSelectionListener, class DiskLayoutPanel extends JPanel implements DiskSelectionListener,
RedoListener, FontChangeListener FileSelectionListener, RedoListener, FontChangeListener
{ {
private static final int SIZE = 15; // basic unit of a display block private static final int SIZE = 15; // basic unit of a display block
@ -169,7 +173,7 @@ class DiskLayoutPanel extends JPanel implements DiskSelectionListener, FileSelec
int y = da.getBlock () / grid.width; int y = da.getBlock () / grid.width;
int x = da.getBlock () % grid.width; int x = da.getBlock () % grid.width;
Rectangle r = Rectangle r =
new Rectangle (x * block.width, y * block.height, block.width, block.height); new Rectangle (x * block.width, y * block.height, block.width, block.height);
return r; return r;
} }
@ -227,7 +231,7 @@ class DiskLayoutPanel extends JPanel implements DiskSelectionListener, FileSelec
{ {
if (newDisk instanceof DualDosDisk) if (newDisk instanceof DualDosDisk)
newDisk = ((DualDosDisk) newDisk).getCurrentDisk (); // never set to a Dual-dos disk newDisk = ((DualDosDisk) newDisk).getCurrentDisk (); // never set to a Dual-dos disk
if (newDisk != image.disk) if (newDisk != image.getDisk ())
{ {
LayoutDetails layout = new LayoutDetails (newDisk); LayoutDetails layout = new LayoutDetails (newDisk);
image.setDisk (newDisk, layout); image.setDisk (newDisk, layout);

View File

@ -108,12 +108,14 @@ public class ProdosDisk extends AbstractFormattedDisk
sectorTypes[vdh.bitMapBlock + i] = volumeMapSector; sectorTypes[vdh.bitMapBlock + i] = volumeMapSector;
parentNode.setUserObject (vdh); // populate the empty volume node parentNode.setUserObject (vdh); // populate the empty volume node
break; break;
case ProdosConstants.TYPE_SUBDIRECTORY_HEADER: case ProdosConstants.TYPE_SUBDIRECTORY_HEADER:
localHeader = new SubDirectoryHeader (this, entry, parent); localHeader = new SubDirectoryHeader (this, entry, parent);
headerEntries.add (localHeader); headerEntries.add (localHeader);
currentSectorType = subcatalogSector; currentSectorType = subcatalogSector;
sectorTypes[block] = currentSectorType; sectorTypes[block] = currentSectorType;
break; break;
case ProdosConstants.TYPE_SUBDIRECTORY: case ProdosConstants.TYPE_SUBDIRECTORY:
FileEntry ce = new FileEntry (this, entry, localHeader, block); FileEntry ce = new FileEntry (this, entry, localHeader, block);
fileEntries.add (ce); fileEntries.add (ce);
@ -122,6 +124,7 @@ public class ProdosDisk extends AbstractFormattedDisk
parentNode.add (directoryNode); parentNode.add (directoryNode);
processDirectoryBlock (ce.keyPtr, ce, directoryNode); // Recursion !! processDirectoryBlock (ce.keyPtr, ce, directoryNode); // Recursion !!
break; break;
case ProdosConstants.TYPE_SEEDLING: case ProdosConstants.TYPE_SEEDLING:
case ProdosConstants.TYPE_SAPLING: case ProdosConstants.TYPE_SAPLING:
case ProdosConstants.TYPE_TREE: case ProdosConstants.TYPE_TREE:
@ -133,6 +136,7 @@ public class ProdosDisk extends AbstractFormattedDisk
node.setAllowsChildren (false); node.setAllowsChildren (false);
parentNode.add (node); parentNode.add (node);
break; break;
default: default:
System.out.println ("Unknown storage type : " + storageType); System.out.println ("Unknown storage type : " + storageType);
System.out.println (HexFormatter.format (entry, 0, entry.length)); System.out.println (HexFormatter.format (entry, 0, entry.length));
@ -168,6 +172,7 @@ public class ProdosDisk extends AbstractFormattedDisk
int bitMapBlock = HexFormatter.intValue (buffer[0x27], buffer[0x28]); int bitMapBlock = HexFormatter.intValue (buffer[0x27], buffer[0x28]);
if (bitMapBlock != 6) if (bitMapBlock != 6)
return false; return false;
return true; return true;
} }