[comp.sys.apple] Reading Apple II format diskettes on Commodore 1541 drive

U267105@HNYKUN11.BITNET (Jos Grote Punt) (01/06/88)

I own a Commodore 64 with 1541 disk drive. I'd like to write a program to read
Apple II (or Apple III) formatted disks . But to do so I need some info on the
disk format. There are some things the same for the Commodore 1541 format, so
I'll alse give some info on that.
I know there are 35 tracks and Apple uses GCR encoding (same as Commodore).
The format can be divided in 2 parts: physical and logical.
Physical format:
- single or double sided (CBM: single)
- number of tracks (CBM: 35)
- number of sectors per track (CBM: varying from 17 to 21)
- starting track number (CBM: 1)
- starting sector number (CBM: 0)
- number of bytes per sector (CBM: 256)
- bit density (CBM: varying, 4000 to 6000 bits per inch)

On a CBM disk the structure of a sector is as follows:
1) "sync" bytes
2) header block
3) "sync" bytes (same as 1)
4) data block
5) inter-sector gap

1) consists of 10 of more 1's in a row (usually 40). These are not GCR encoded.
2) a) HEADER BLOCK ID: this is always 8 and indicates that this is a header.
   b) HEADER BLOCK CHECKSUM: this is an exclusive OR of tracknumber, sector-
      number and the 2 id bytes
   c) SECTOR NUMBER
   d) TRACK NUMBER
   e) first ID BYTE
   f) second ID BYTE
   g) two so called OFF bytes, value is 0F hex . These are for padding and
      never read by the drive.
   h) HEADER GAP: consists of eight 55 hex bytes, not GCR encoded. This is
      breathing room for the drive, they are never read

3) a) DATA BLOCK ID: this is always 7 and indicates that this is a data block
   b) 256 data bytes
   c) DATA BLOCK CHECKSUM: an exclusive OR of all data bytes
   d) two so called OFF bytes, value is 0. They are for padding and never read
      by the drive.

4) The gap has a varying length and is never read (the drive just waits for the
   next SYNC character.

The GCR table used is as follows:

nybble in memory             5-bit value on drive
00                           01010
01                           01011
02                           10010
03                           10011
04                           01110
05                           01111
06                           10110
07                           10111
08                           01001
09                           11001
0A                           11010
0B                           11011
0C                           01101
0D                           11101
0E                           11110
0F                           10101

Please E-mail me directly, since I'm not a member of this list. My address is:
Jos Grote Punt
Dept. of Geography
University of Nymegen
The Netherlands

U267105 AT HNYKUN11.BITNET

Thanks in advance,

                     Jos
Acknowledge-To: <U267105@HNYKUN11>