bug in switching block size

This commit is contained in:
Denis Molony 2016-02-29 05:53:59 +11:00
parent 087ad914b4
commit cd24a6b780
3 changed files with 18 additions and 13 deletions

View File

@ -99,6 +99,8 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
for (DiskAddress da : disk)
sectorTypes[da.getBlock ()] = disk.isSectorEmpty (da) ? emptySector : usedSector;
setGridLayout ();
}
private void setGridLayout ()
@ -109,15 +111,19 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
case 280:
gridLayout = new Dimension (8, 35);
break;
case 455:
gridLayout = new Dimension (13, 35);
break;
case 560:
gridLayout = new Dimension (16, 35);
break;
case 1600:
gridLayout = new Dimension (16, 100);
break;
default:
int[] sizes = { 32, 20, 16, 8 };
for (int size : sizes)
@ -131,6 +137,12 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
}
}
@Override
public Dimension getGridLayout ()
{
return gridLayout;
}
@Override
public Disk getDisk ()
{
@ -379,12 +391,6 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
}
}
@Override
public Dimension getGridLayout ()
{
return gridLayout;
}
// VTOC flags sector as free, but it is in use by a file
@Override
public int falsePositiveBlocks ()

View File

@ -343,12 +343,14 @@ public class AppleDisk implements Disk
assert (size == 256 || size == 512) : "Invalid sector size : " + size;
if (sectorSize == size)
return;
sectorSize = size;
sectors = trackSize / sectorSize;
blocks = tracks * sectors;
System.out.printf ("New blocks: %d%n", blocks);
hasData = new boolean[blocks];
checkSectorsForData ();
if (actionListenerList != null)
notifyListeners ("Sector size changed");
}

View File

@ -84,10 +84,6 @@ class DiskLayoutImage extends JPanel implements Scrollable
{
super.paintComponent (g);
// why doesn't linux do this?
// g.setColor (Color.WHITE);
// g.fillRect (0, 0, getWidth (), getHeight ());
if (disk == null)
return;
@ -102,8 +98,9 @@ class DiskLayoutImage extends JPanel implements Scrollable
List<DiskAddress> selectedBlocks = selectionHandler.getHighlights ();
// this stops an index error when using alt-5 to switch to 512-byte blocks
if (maxBlock > d.getTotalBlocks ())
maxBlock = d.getTotalBlocks ();
// if (maxBlock > d.getTotalBlocks ())
// maxBlock = d.getTotalBlocks ();
// the index error is caused by not recalculating the grid layout
for (int y = p1.y; y <= p2.y; y += bh)
for (int x = p1.x; x <= p2.x; x += bw)