/* * AppleCommander - An Apple ][ image utility. * Copyright (C) 2002 by Robert Greene * robgreene at users.sourceforge.net * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package com.webcodepro.applecommander.storage; import java.util.ArrayList; import java.util.BitSet; import java.util.Iterator; import java.util.List; /** * Manages a disk that is in the RDOS format. *
* Note that the RDOS block interleave is different than the standard DOS 3.3 format. * Thus, when the image is made, the sectors are skewed differently - use readRdosBlock * to read the appropriate block number. *
* Also note that the operating system is itself the first file. Block #0 is really * track 0, sector 0 - meaning that the first file should not (cannot) be deleted. *
* RDOS appears to have been placed on 13 sector disks. This limits the number of blocks * to 455. It also may also cause incompatibilities with other formats and other cracks. *
* Date created: Oct 7, 2002 2:03:58 PM * @author: Rob Greene */ public class RdosFormatDisk extends FormattedDisk { /** * Specifies the length of a file entry. */ public static final int ENTRY_LENGTH = 0x20; /** * Specifies the number of blocks on the disk. * RDOS apparantly only worked on 5.25" disks. */ public static final int BLOCKS_ON_DISK = 455; /** * Use this inner interface for managing the disk usage data. * This offloads format-specific implementation to the implementing class. * A BitSet is used to track all blocks, as RDOS disks do not have a * bitmap stored on the disk. This is safe since we know the number of blocks * that exist. (BitSet length is of last set bit - unset bits at the end are * "lost".) *
* Note one really unique point about RDOS - the entire disk is mapped out
* by the file entries. There are no blocks marked off, by default, by the
* operating system. However, the first file (RDOS itself) starts on block
* 0 (track 0, sector 0) and runs for 26 blocks - which covers all of track 0
* (the operating system) and the 10 sectors used for file entries.
*/
private class RdosDiskUsage implements DiskUsage {
private int location = -1;
private BitSet bitmap = null;
public boolean hasNext() {
return location == -1 || location < BLOCKS_ON_DISK - 1;
}
public void next() {
if (bitmap == null) {
bitmap = new BitSet(BLOCKS_ON_DISK);
// mark all blocks as unused
for (int b=0; b