From 62c7b5bc70cadd2145c3f83774f33394888b1da8 Mon Sep 17 00:00:00 2001 From: Robert Greene Date: Thu, 12 Dec 2002 01:54:01 +0000 Subject: [PATCH] Added ability to create and format a disk. Routines were centralized a bit and the various file entries now read and write directly to the disk image. --- .../storage/ProdosFormatDisk.java | 194 +++++++++++++----- 1 file changed, 146 insertions(+), 48 deletions(-) diff --git a/src/com/webcodepro/applecommander/storage/ProdosFormatDisk.java b/src/com/webcodepro/applecommander/storage/ProdosFormatDisk.java index 8a04e0c..81af7c6 100644 --- a/src/com/webcodepro/applecommander/storage/ProdosFormatDisk.java +++ b/src/com/webcodepro/applecommander/storage/ProdosFormatDisk.java @@ -20,6 +20,7 @@ package com.webcodepro.applecommander.storage; import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -29,11 +30,6 @@ import java.util.List; * @author: Rob Greene */ public class ProdosFormatDisk extends FormattedDisk { - /** - * The standard ProDOS file entry length. - */ - public static final int ENTRY_LENGTH = 0x27; - /** * Hold on to the volume directory header. */ @@ -60,20 +56,9 @@ public class ProdosFormatDisk extends FormattedDisk { throw new IllegalArgumentException("Invalid dimension for isFree! Did you call next first?"); } if (data == null) { - int volumeBitmapBlock = volumeHeader.getBitMapPointer(); - int volumeBitmapBlocks = volumeHeader.getTotalBlocks(); - int blocksToRead = (volumeBitmapBlocks / 4096) + 1; - // Read in the entire volume bitmap: - data = new byte[blocksToRead * BLOCK_SIZE]; - for (int i=0; i 2) ? block-1 : 0; + AppleUtil.setWordValue(data, 0, prevBlock); + AppleUtil.setWordValue(data, 2, nextBlock); + writeBlock(block, data); + } + // setup volume header information (each set will also save data) + volumeHeader.setVolumeHeader(); + volumeHeader.setVolumeName(volumeName); + volumeHeader.setCreationDate(new Date()); + volumeHeader.setProdosVersion(0); + volumeHeader.setMinimumProdosVersion(0); + volumeHeader.setChanged(true); + volumeHeader.setDestroy(true); + volumeHeader.setRead(true); + volumeHeader.setRename(true); + volumeHeader.setWrite(true); + volumeHeader.setEntryLength(); + volumeHeader.setEntriesPerBlock(); + volumeHeader.setFileCount(0); + volumeHeader.setBitMapPointer(6); + volumeHeader.setTotalBlocks(totalBlocks); + // setup bitmap usage + byte[] bitmap = readVolumeBitMap(); + for (int block=0; block