[HOWTO] - Access CP/M Floppy's via libdsk & cpmtools

Share your own howto's etc. Not for support questions!

[HOWTO] - Access CP/M Floppy's via libdsk & cpmtools

Postby lkraemer » 2014-03-04 23:38

[HOWTO] - Access CP/M Floppy's created with Teledisk using libdsk & cpmtools

This HOWTO: will explain how to Install libdsk Version 1.3.5 & cpmtools Version 2.18, along with the dependencies, that allow READ ONLY
access to Teledisk (*.TD0) files with your Debian 7.x install.

BEFORE YOU TRY A COMPILE YOU MUST INSTALL SOME REQUIRED SOFTWARE:
Typically you need to install build-essential, and the headers for the kernel you are running.

Debian Wheezy (Ver 7.x) Packages needed for Software Compile:
1. Build-Essential
2. Linux debian 3.2.0-4-amd64 Headers (or the Headers for your Version)
Code: Select all
uname -r

will tell you the kernel you are currently running.

Code: Select all
sudo apt-get install build-essential linux-headers-$(uname -r)

will install the software needed to successfully compile your source code.

Install Additional Required Software to Compile libdsk and cpmtools:
Install libncurses5-dev:
Code: Select all
sudo apt-get install libncurses5-dev


At this point you may have had several directory changes or updates, and your system likely needs updated with:
Code: Select all
sudo updatedb

It's a good idea to execute this command at a regular interval, to keep the database updated for the locate command.


DOWNLOAD THE SOURCE:
Create a new subdirectory of your choice to contain the downloaded source code.
Download both source packages from:

http://www.seasip.info/Unix/LibDsk/libdsk-1.3.5.tar.gz
http://www.moria.de/~michael/cpmtools/c ... .18.tar.gz

Create a subdirectory to contain the source. I used /home/larry/Downloads/cpmtools
Copy both source files to /home/larry/Downloads/cpmtools, then extract the source folders
Code: Select all
tar -zxvf libdsk-1.3.5.tar.gz
tar -zxvf cpmtools-2.18.tar.gz

The next step you need to do is to find the "SHELL" and "env" you are using, and how many shells are installed and available.

1. env -- Display the current environment, find what Shell is being used with the following command.....
Code: Select all
env | grep SHELL=

To get a list of available shells on your system, look in the /etc/shells file. This will list the available shells with their complete
path names. You can see the list of available shells by running:
Code: Select all
cat /etc/shells

Additional shells may be available in your distribution's software repositories. Performing a search for the term "shell" in your
package manager should provide you with a list of alternative command line shells.

If you want to experiment with a shell, just for now, you can launch a shell from within the existing shell. For example, if you
ant to run the tcsh shell, you can run:
Code: Select all
tcsh

When you are finished exploring tcsh you can type exit to return to the default shell. Once you have found a shell you want to continue using
you can switch to the default shell by running the chsh command. For example, if you want to switch to using the tcsh shell, you can run
Code: Select all
chsh -s /usr/bin/tcsh

Please note that you must provided the full directory path to the new shell.

2. locate .*rc -- Find the current logged in user's home shell Configuration file (*rc)... use:
Code: Select all
locate .*rc

REF:
http://en.wikipedia.org/wiki/Unix_shell
Bourne shell (sh)
Almquist shell (ash)
Bourne-Again shell (bash)
Debian Almquist shell (dash)
Korn shell (ksh)
Z shell (zsh)
C shell (csh)
TENEX C shell (tcsh)
other shells..............

There may be a .bash_profile file in /home/loginuser along with .bashrc file. You can put configurations in either file,
and you can create either if it doesn’t exist. But, why two different files? What is the difference?

According to the bash man page, .bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.

If .bash_profile exists in /home/user with the following information already inserted:
Code: Select all
PATH=$PATH:$HOME/bin
export PATH

just append your path modifications here instead of the .bashrc file. (ie. CentOS 6)

You need to list the *rc file to verify the contents and set the PATHS. I'm ASSUMING a Bash shell......Your may be different!

3. cat .bashrc -- List the configuration file, then append the proper search paths for the users shell with edit.
Code: Select all
export LD_LIBRARY_PATH=????????????????????????????????
export LIBRARY_PATH=???????????????????????????????????
export C_INCLUDE_PATH=?????????????????????????????????
export CPATH=??????????????????????????????????????????

Mine happens to now be:
Code: Select all
export LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
export LIBRARY_PATH=/usr/lib:/usr/local/lib
export C_INCLUDE_PATH=.:/usr/include:/usr/local/include
export CPATH=.:/usr/include:/usr/local/include

But, your's may vary accordingly. You won't be able to cut & paste mine, unless your system is built exactly like mine. It's up to you to locate
exactly where all the libs and includes are located. That is what all the previous commands should have helped you do. Just because you have
/usr/lib & /usr/local/lib included....doesn't mean your needed lib is in that path.

That is where your detective work comes to play. SEARCH and use grep to locate the libs.

Once you have the env set either reboot or reset the env. Once again, your system command for this can/may be different.

4. source .bashrc -- Reset the environment to what we need for Compiles, assuming the SHELL is bash. This may not be available on your system.....

REF:
http://linux.about.com/library/cmd/blcmdl1_ulimit.htm
source filename [arguments]
Read and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename.v If filename does not contain a slash, file names in PATH are used to find the directory containing filename. vThe file searched for in PATH need not be executable. vWhen bash is not in posix mode, the current directory is searched if no file is found in PATH. vIf the sourcepath option to the shopt builtin command is turned off, the PATH is not searched. vIf any arguments are supplied, they become the positional parameters when filename is executed. vOtherwise the positional parameters are unchanged. vThe return status is the status of the last command exited within the script (0 if no commands are executed), and false if filename is not found or cannot be read.


VERIFY the env is correct:

5. env -- Display the new environment to verify the paths.............PARTIAL DISPLAY of SPECIFIC's I NEEDED...
Code: Select all
LIBRARY_PATH=/usr/lib:/usr/local/lib
LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
CPATH=.:/usr/include:/usr/local/include
C_INCLUDE_PATH=.:/usr/include:/usr/local/include



Append the new CP/M Floppy Disk Definitions for cpmtools to the /usr/local/share/diskdefs file.
Append these sample diskdefs to /usr/local/share/diskdefs & /etc/cpmtools/diskdefs

Additional Definitions for diskdefs:
Code: Select all
diskdef amp1
  seclen 512      #= Sectors xx,512
  tracks 40       #= (Cylinders * Sides) = 40*1 = 40
  sectrk 10       #= Sectors 10,xxx
  blocksize 2048  #= (128*(BLM+1)) = 2048                               
  maxdir 64       #= (DRM+1) = 64
  skew 0          #= SKEW 0
  boottrk 2       #= OFS = 2
  os 2.2
end

# setfdprm /dev/fd0 DS DD ssize=512 cyl=40 sect=10 head=2
diskdef amp2
  seclen 512
  tracks 80
  sectrk 10
  blocksize 2048
  maxdir 128
  skew 0
  boottrk 2
  os 2.2
end

# setfdprm /dev/fd0 zerobased SS DD ssize=512 cyl=40 sect=10 head=1
# Kaypro II
diskdef kpii
  seclen 512
  tracks 40
  sectrk 10
  blocksize 1024
  maxdir 64
  skew 0
  boottrk 1
  os 2.2
end

# setfdprm /dev/fd0 zerobased DS DD ssize=512 cyl=40 sect=10 head=2
# Kayro IV
diskdef kpiv
  seclen 512
  tracks 80
  sectrk 10
  blocksize 2048
  maxdir 64
  skew 0
  boottrk 1
  os 2.2
end

diskdef zor1
  seclen 512     
  tracks 80     
  sectrk 10     
  blocksize 2048                             
  maxdir 64     
  skew 0       
  boottrk 2   
  os 2.2
end

diskdef zor2
  seclen 512     
  tracks 160     
  sectrk 10       
  blocksize 4096                               
  maxdir 128     
  skew 0       
  boottrk 2   
  os 2.2
end


UPDATE: 08/13/2014 cpmtools Version 2.19 has been released with additional disk definitions
I've attached my definition file because I've added (and tested) several additional definitions.
CORRECTED SKEW=2 in Radio Shack Model 4 CP/M Definitions.

diskdefs.zip
diskdefs.zip
(6.67 KiB) Downloaded 193 times


Copy these sample libdskrc definitions to an External file at /home/user/.libdskrc
.libdskrc contains:
Code: Select all
[amp1]
description = Ampro - SSDD 48 tpi 5.25"
cylinders = 40
heads = 1
sectors = 10
secbase = 1
secsize = 512
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y

[amp2]
description = Ampro - DSDD 48 tpi 5.25"
sides=alt
cylinders = 40
heads = 2
sectors = 10
secbase = 17
secsize = 512
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y

[kpii]
description = Kaypro II/2 - SSDD 48 tpi 5.25"
cylinders = 40
heads = 1
sectors = 10
secbase = 0
secsize = 512
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y

[kpiv]
description = Kaypro 2X/4/10 - DSDD 48 tpi 5.25"
cylinders = 80
heads = 2
sectors = 10
secbase = 0
secsize = 512
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y

[zor1]
description = Zorba - DSDD 48 tpi 5.25"
sides=alt
cylinders = 80
heads = 2
sectors = 10
secbase = 1
secsize = 512
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y

[zor2]
description = Zorba - DSDD 48 tpi 5.25"
sides=alt
cylinders = 160
heads = 2
sectors = 10
secbase = 1
secsize = 512
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y


Code: Select all
sudo cp diskdefs /usr/local/share/diskdefs
sudo cp diskdefs /etc/cpmtools/diskdefs
cp .libdskrc /home/user/.libdskrc



TYPICAL COMPILE STEPS: (from within your source directory)
Code: Select all
./configure
make clean
make
sudo make install

"make clean" won't remove anything on the first compile, but will clean up on a successive compile.

Build libdsk:
Code: Select all
cd ~/Downloads/cpmtools
cd libdsk-1.3.5
./configure
make
sudo make install
sudo make install-man


Build cpmtools:
Code: Select all
cd ..
cd cpmtools-2.18
./configure --with-libdsk=/usr/local
make
sudo make install


VERIFY cpmls executes properly:
Code: Select all
cd ..
cpmls


If you don't get the following cli usage message:
Usage: cpmls [-f format] [-T libdsk-type] [-d|-D|-F|-A|[-l][-c][-i]] image [file ...]

try this command:
Code: Select all
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/usr/local/lib"

Then do:
Code: Select all
cpmls


Open a Teledisk *.TD0 file containing compressed CP/M Files, and view the CP/M Directory with the following commands:
Code: Select all
man cpmls
cpmls -f kpii -T tele,kpii -d kii-b282.td0
cpmls -f kpiv -T tele,kpiv -l KAY2SYS.td0
cpmls -f amp1 -T tele,amp1 -i ampro.td0
cpmls -f zor1 -T tele,zor1 -l compat32.td0
cpmls -f zor1 -T tele,zor1 -d compat32.td0
man cpmcp
cpmcp -f a1 bb2mon.img 0:*.mac /home/larry/Downloads/cpmtools/xfer1


larry@debian:~/Downloads/cpmtools$ cpmls -f zor1 -T tele,zor1 -l compat32.td0
0:
-rwxrwxrwx 19072 Dec 31 1969 compat.com
-rwxrwxrwx 22784 Dec 31 1969 format.com
-rwxrwxrwx 4352 Dec 31 1969 install.com
-rwxrwxrwx 11008 Dec 31 1969 ms.com
-rwxrwxrwx 9472 Dec 31 1969 mycopy.com
-rw-rw-rw- 1408 Dec 31 1969 z2000q.hex
-rw-rw-rw- 4480 Dec 31 1969 z2000q.prl
-rw-rw-rw- 1280 Dec 31 1969 zorbad.hex
-rw-rw-rw- 4224 Dec 31 1969 zorbad.prl
-rw-rw-rw- 1280 Dec 31 1969 zorbaq.hex
-rw-rw-rw- 4352 Dec 31 1969 zorbaq.prl
larry@debian:~/Downloads/cpmtools$


larry@debian:~/Downloads/cpmtools$ cpmls -f zor1 -T tele,zor1 -d compat32.td0
COMPAT COM : FORMAT COM : MS COM : INSTALL COM
MYCOPY COM : ZORBAD PRL : ZORBAD HEX : ZORBAQ PRL
ZORBAQ HEX : Z2000Q PRL : Z2000Q HEX
larry@debian:~/Downloads/cpmtools$


THANKS to John Elliott (libdsk) & Michael Haardt (cpmtools) for developing each software package.


PM me with a valid email address if you would like a CP/M *.TD0 file to test.

Larry
Last edited by lkraemer on 2017-09-19 11:44, edited 6 times in total.
lkraemer
 
Posts: 175
Joined: 2011-02-09 05:02

Re: [HOWTO] - Access CP/M Floppy's via libdsk & cpmtools

Postby lkraemer » 2014-03-11 00:02

Now that you need to modify or add CP/M definitions to 22DISK, LIBDSK, and/or CPMTOOLS, this document will assist you
with locating the proper parameters for the three definition files for:

22DISK - CPMDISKS.DEF
LIBDSK - .libdskrc
CPMTOOLS - diskdefs
Code: Select all
~/path/to/your/22Disk/CPMDISKS.DEF
/home/user/.libdskrc
/usr/local/share/diskdefs  (also located at /etc/cpmtools/diskdefs)



Some Helpful Hints on Developing a Disk Definition from Scratch

If possible, run programs on the CP/M system to help get the necessary information for building a
new definition. The following files may be transferred by RS-232C if a Terminal Program is available,
or by PIPMODEM.COM (PIPMODEM.DOC & PIPMODEM.ASM)

1. CPMADR.COM - Finds addresses used by the CP/M system.

2. DPB.COM - Finds Disk Parameter Block information.
DPB.BAS - Same, but runs under MBASIC. (Located in 22DISK.TXT)

3. PROBE.COM - Probes CP/M System and Drive for information.
Note: The previous four programs may not locate and
display accurate information for some CP/M systems.

4. SKEW.COM - Finds disk SKEW information.

5. Execute the following "STAT" commands on system in question.
Note: "Control P" will allow a hardcopy of the information.

STAT DEV: - Displays current DEVICE information.
STAT VAL: - Displays current STATUS information.
STAT USR: - Displays current USR information.
STAT A*.* $S - Displays detailed file information.
STAT DSK: - Gives some detailed disk information for logged drive.
STAT A: DSK: - Gives some detailed disk information for A:.
STAT B: DSK: - Gives some detailed disk information for B:.

If you have a functional CP/M system, you can use DDT to find the Disk Parameter Block and the
information is stored there for each drive.

1. Log the drive you wish to locate the DPB data for. I will use A; for this example
2. Run DDT and enter the code below:
DDT
-f0100,0200,00
-A0100
0100 mvi c,1f
0102 call 5
0105 rst 7
0106 . #period to exit assembler
-d0100
0100 0e1fcd0500FF
-g0100
*105
-x #display register HL
The contents of register HL is the address of Drive A: DPB. If you display that address
(mine was F5E3) you will see F5E3: 2400040F0154007F00C00020000200.


RPT = 0024 = The number of 128 byte records per track.
BSH = 04 = The block shift count.
BLM = 0F = The block mask.
EXM = 01 = The extent mask.
DSM = 0054 = Disk storage maximum (the largest block number).
DRM = 007F = Directory maximum (the largest directory entry).
DAB = 00C0= Directory Allocation Block AL0: = 00 & AL1: = C0
CKS = 00020 = Directory check size.
OFF = 0002 = Track offset (number of reserved tracks).


SPT: Number of sectors per track. May differ from RPT if physical sectors
are other than 128 bytes in size.


SSZ: Sector size code:
0 = 128 bytes per sector
1 = 256 bytes per sector
2 = 512 bytes per sector
3 = 1024 bytes per sector


NTK: Number of tracks (35, 40, 77, or 80). The number of tracks can be determined by formatting
a Floppy, or with Anadisk. Anadisk will also tell you the sector size and SKEW.


Quite frequently, the only information available when developing a definition for 22DISK is a
diskette with a few files and nothing more.

Here's a guide on what to do if you'd like to try working up a definition yourself:

1. Get a copy of Sydex's ANADISK. This utility will furnish far more information than will any
other program. A typical disk definition follows:

Ampro Little Board Z80 running CP/M 2.21
BEGIN AMP1 Ampro - SSDD 48 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 40 SIDES 1 SECTORS 10,512 SKEW 2
SIDE1 0 1,2,3,4,5,6,7,8,9,10
BSH 4 BLM 15 EXM 1 DSM 94 DRM 63 AL0 080H AL1 0 OFS 2
END

New 22DISK definitions require the following information:

DENSITY xx,xx
CYLINDERS xx
SIDES xx
SECTORS x,xxxx
SKEW x
SIDE1 0 x,x1,x2,x3, , ,xn
SIDE2 x x,x1,x2,x3, , ,xn
ORDER x
BSH x
BLM x
EXM x
DSM x
DRM x
AL0 x
AL1 x
OFS x (or SOFS x)
COMPLEMENT (unlikely)

New LIBDSK definitions require the following information:

[title]
description = DESC The description of the format as shown by (for example) dskform–help.
sidedness =TREATMENT How a double-sided disk is handled. This can either be alt
(sides alternate – used by most PC-hosted operating systems),
outback (use side 0 tracks 0-79, then side 1 tracks 79-0 – used
by 144FEAT CP/M disks), or outout (use side 0 tracks 0-79, then
side 1 tracks 0-79 – used by some Acorn formats). If the disk is
single-sided, this parameter can be omitted.
cylinders = COUNT Sets the number of cylinders (usually 40 or 80).
heads = COUNT Sets the number of heads (usually 1 or 2 for single- or double- sided).
sectors = COUNT Sets the number of sectors per track.
secbase = NUMBER Sets the first sector number on a track. Usually 1; some Acorn formats use 0.
secsize = COUNT Sets the size of a sector in bytes. This should be a power of 2.
datarate = VALUE Sets the rate at which the disk should be accessed. This is one of: HD, DD, SD or ED.
rwgap = VALUE Sets the read/write gap.
fmtgap = VALUE Sets the format gap.
fm = Y or N Sets the recording mode - Y for FM, N for MFM.
multitrack = Y or N Sets multitrack mode.
skipdeleted = Y or N Sets whether to skip deleted data.

The LIBDSK Data rate will be one of:
RATE_HD, /* Rate for High-density disc - 1.2Mb in 5.25" 96 tpi drive, or 1.44Mb in 3.5" 96 tpi drive */
RATE_DD, /* Rate for Double-density disc - 360k in 5.25" 48 tpi drive, or 720K in 3.5" 48 tpi drive */
RATE_SD, /* Rate for Double-density disc - 180k in 5.25" 48 tpi drive, or 360k in 3.5" 48 tpi drive */
RATE_ED /* Data rate for 2.8Mb 3.5" in 3.5" 96 tpi drive */


New CPMTOOLS definitions require the following information:

diskdef title
seclen xxx #= Sectors xx,1024
tracks xx #= (Cylinders * Sides) = 80*2 = 160
sectrk xx #= Sectors 5,xxx
blocksize xxxx #= (128*(BLM+1)) = 2048
maxdir xxx #= (DRM+1) = 256
skew x #= may be 1 thru 6, or so
boottrk x #= OFS = 2
os x.x #= 2.2, or 2, or 3
end

So, if you know the 22DISK parameters, you can easily fill in the details for LIBDSK & CPMTOOLS. As an
example, here is an AMPRO LITTLE BOARD DSDD 96 tpi 5.25" Definition for all three software packages.

BEGIN AMP4 Ampro - DSDD 96 tpi 5.25"
DENSITY MFM,LOW
CYLINDERS 80 SIDES 2 SECTORS 5,1024 SKEW 2
SIDE1 0 17,18,19,20,21
SIDE2 1 17,18,19,20,21
ORDER SIDES
BSH 4 BLM 15 EXM 0 DSM 394 DRM 255 AL0 0F0H AL1 0 OFS 2
END

[amp4]
description = Ampro - DSDD 96 tpi 5.25"
sides=alt #=/* XXX Provisional depending on 22DISK Definition */
cylinders = 80 #= Cylinders = 80
heads = 2 #= Sides = 2
sectors = 5 #= Sectors 5,xxx
secbase = 17 #= First Sectors from (SIDE1 0 17)
secsize = 1024 #= Sectors xx,1024
datarate = DD #= Data Rate = SD, DD, HD, ED
rwgap = 12 #=/* XXX Provisional */
fmtgap = 23 #=/* XXX Provisional */
fm = N #= FM or MFM (Likely MFM)
multitrack = N #= Most likely N
skipdeleted = Y #= Most likely Y

diskdef AMP4
seclen 1024 #= Sectors xx,1024
tracks 160 #= (Cylinders * Sides) = 80*2 = 160
sectrk 5 #= Sectors 5,xxx
blocksize 2048 #= (128*(BLM+1)) = 2048
maxdir 256 #= (DRM+1) = 256
skew 0 #= may be 1 thru 6, or so
boottrk 2 #= OFS = 2
os 2.2 #= 2.2, or 2, or 3
end

2. Run ANADISK on the diskette in SECTOR EDIT mode with the display set for "HEX".
Note that the interleave (or SKEW) is given, as well as the number, size and addresses of
sectors. You now have data for: DENSITY, CYLINDERS, SIDES, SKEW SIDE1 and SIDE2.

3. Locate the directory on the diskette. Almost invariably, it starts on the first sector of a track.
If for some reason it can't be found on the first sector of a track, try using the SEARCH feature
to find a "FILE" name that exists on the disk. The number of tracks or sectors up the point
where the directory begins will give the figure for OFS or SOFS. The directory stands out
because it shows file names every 32 bytes, or every other line on the ANADISK display.

Directory was located at Cylinder 0, Side 0, Sector 2:

0000 00 32 32 44 49 53 4b 20 20 44 4f 43 00 00 00 80 .22DISK DOC....
0010 02 00 03 00 04 00 05 00 06 00 07 00 08 00 09 00 ................
0020 00 32 32 44 49 53 4b 20 20 44 4f 43 01 00 00 80 .22DISK DOC....
0030 0a 00 0b 00 0c 00 0d 00 0e 00 0f 00 10 00 11 00 ................
0040 00 32 32 44 49 53 4b 20 20 44 4f 43 02 00 00 80 .22DISK DOC....
0050 12 00 13 00 14 00 15 00 16 00 17 00 18 00 19 00 ................
0060 00 32 32 44 49 53 4b 20 20 44 4f 43 03 00 00 80 .22DISK DOC....
0070 1a 00 1b 00 1c 00 1d 00 1e 00 1f 00 20 00 21 00 ............ .!.
0080 00 32 32 44 49 53 4b 20 20 44 4f 43 04 00 00 08 .22DISK DOC....
0090 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "...............
00a0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
00b0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
00c0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
00d0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
00e0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
00f0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0100 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0110 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0120 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0130 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0140 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0150 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0160 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0170 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0180 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0190 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
01a0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
01b0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
01c0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
01d0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
01e0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
01f0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................

Fig 1

Directory continues on Cylinder 0, Side 0, Sector 3:

0000 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0010 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0020 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0030 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0040 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0050 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0060 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0070 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0080 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0090 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
00a0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
00b0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
00c0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
00d0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
00e0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
00f0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0100 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0110 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0120 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0130 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0140 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0150 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0160 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0170 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0180 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
0190 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
01a0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
01b0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
01c0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
01d0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
01e0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................
01f0 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 ................

Fig 2


4. Examine the first directory entry. The second 16 bytes (the second line of the entry) gives a list
of allocation unit numbers (AUN) belonging to the file. The first one of these will tell how many
allocation units have been reserved to hold the directory. Thus, if the first allocation byte is 02,
two allocation units have been allocated to the directory. Another thing to note is whether the
allocation unit number appears to be an 8 bit or 16 bit quantity. For example, if an entry has the
following form:

00 50 49 50 20 20 20 20 20 43 4F 4D 00 00 00 10 .PIP COM....
04 00 05 00 06 00 00 00 00 00 00 00 00 00 00 00 ................

the allocation unit designators are 4, 5 and 6 and are 16 bit quantities. On the other hand, the
following item:

00 50 49 50 20 20 20 20 20 43 4F 4D 00 00 00 10 .PIP COM....
04 05 06 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

shows the same allocation units, but as 8 bit quantities. If 16 bit quantities are involved, more
than 255 allocation nits are defined for the diskette, if an 8 bit quantity, less than 256 units.
This serves as a check for later computations. In any case, the first allocation number of the
first directory entry gives the number of bits to be set in AL0 and AL1.

Allocation Unit Number (AUN)
02 AL0 11000000B Al1 0
04 AL0 11110000B Al1 0


The following information shows a detailed breakdown of all the information in the the first and
second directory entries.

00 - Valid file (E5 for Erased File)
32 32 44 49 53 4b 20 20 44 4f 43 - File name 22DISK DOC (11 bytes)
00 - Extent (used for large files)
00 - S1 (Digital Research Reserved)
00 - S2 (Digital Research Reserved)
80 - Number of records in this extent
02 00 03 00 04 00 05 00 06 00 07 00 08 00 09 00 - allocation units

Note: 02 is the first AUN.

00 - (Continuation of above file)
32 32 44 49 53 4b 20 20 44 4f 43 - File name 22DISK DOC (11 bytes)
01 - Extent (used for large files)
00 - S1 (Digital Research Reserved)
00 - S2 (Digital Research Reserved)
80 - Number of records used
0a 00 0b 00 0c 00 0d 00 0e 00 0f 00 10 00 11 00 - allocation units

Note: Unused allocation units will be 00.


5. Starting with the first directory sector, advance the sector (and track, if necessary) until you
find the data belonging to the first file. Unused directory entries are almost always filled out
with a pattern of E5's. The number of sectors dedicated to the directory will give an indication
of both the number of directory entries and the allocation unit size.


First Program located at Cylinder 0, Side 1, Sector 2:
NOTE: (This was the 9th sector displayed, so 8 are reserved for directory)

0000 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 20 20 20 20 ............
0010 20 20 53 79 64 65 78 0d 0a 0d 0a 0d 0a 0d 0a 0d Sydex.........
0020 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d ................
0030 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 20 ...............
0040 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0050 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0060 20 20 20 20 20 32 32 44 49 53 4b 0d 0a 0d 0a 0d 22DISK.....
0070 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
0080 20 20 20 20 20 41 20 43 50 2f 4d 2d 74 6f 2d 44 A CP/M-to-D
0090 4f 53 20 44 69 73 6b 65 74 74 65 20 49 6e 74 65 OS Diskette Inte
00a0 72 63 68 61 6e 67 65 20 55 74 69 6c 69 74 79 0d rchange Utility.
00b0 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d ................
00c0 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d ................
00d0 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 20 ...............
00e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
00f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0100 20 20 20 20 20 20 20 20 20 20 20 20 20 53 79 64 Syd
0110 65 78 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ex..
0120 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0130 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0140 20 20 31 35 33 20 4e 6f 72 74 68 20 4d 75 72 70 153 North Murp
0150 68 79 20 41 76 65 2e 0d 0a 20 20 20 20 20 20 20 hy Ave...
0160 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0170 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0180 20 20 20 20 20 20 20 53 75 6e 6e 79 76 61 6c 65 Sunnyvale
0190 2c 20 43 41 20 20 39 34 30 38 36 0d 0a 20 20 20 , CA 94086..
01a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
01b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
01c0 20 20 20 20 20 20 20 20 20 20 20 28 34 30 38 29 (408)
01d0 20 37 33 39 2d 34 38 36 36 0d 0a 0d 0a 0d 0a 0d 739-4866.......
01e0 0a 0c 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a 0d 0a ................
01f0 0d 0a 0d 0a 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ........

Fig 3


Suppose that a our hypothetical diskette shows 8 sectors of 512 bytes allocated to the directory.
Since a directory entry is 32 bytes long, the number of directory entries possible for this format is:

16 entries/sector X 8 sectors = 128 entries total
or
((Sector Size in Bytes/32) X Sectors to DIR) -1 = DRM


Thus, DRM is one less than this or 127. Since we know that these 8 sectors represent 2 allocation
units or 4,096 bytes, the Allocation Unit Size (AUS) is:

4,096 / 2 = 2,048 bytes
or
((Sector Size in Bytes) X Sectors to DIR) / AUN = AUS

Given this, we can use the following table to compute the values for BSH and BLM:


+--------------+-------------+------------+
| Unit Size | BSH | BLM |
+--------------+-------------+------------+
| 1,024 | 3 | 7 | +----------+
| 2,048 | 4 | 15 | ------+ This one |
| 4,096 | 5 | 31 | +----------+
| 8,192 | 6 | 63 |
| 16,384 | 7 | 127 |
+--------------+-------------+------------+


7. We still need a value for EXM and DSM. DSM is simply the total number of allocation units
on the diskette, not counting the system OFS area. Let's assume that our diskette has an offset
of 2 tracks and is single-sided with 40 cylinders with 8 sectors per track. The value of DSM
is then:

((40 cylinders X 1 side) - 2 tracks) X 8 sectors X 512 bytes) =
155,648 bytes / 2,048 = 76 Allocation units, total

To get EXM, we then use the following table:

+--------------+-------------+-------------+
| Unit Size | DSM < 256 | DSM > 255 |
+--------------+-------------+-------------+
| 1,024 | 0 | na |
| 2,048 | 1 | 0 |
| 4,096 | 3 | 1 |
| 8,192 | 7 | 3 |
| 16,384 | 15 | 7 |
+--------------+-------------+-------------+


8. That's almost the complete picture, but for the SIDE1 and SIDE2 sector ordering. This is the
hardest to determine of any of the parameters. Find a readable text file on the diskette and
piece the text back together by observing how words break across sector boundaries. After a
bit, a pattern in the ordering will become apparent, such as:

1, 3, 5, 7, 2, 4, 6, 8


9. The ORDER value can be determined on double-sided diskettes by observing whether file
data appears to move from one track to the next on the same side (CYLINDERS), or appears to
go from one side to the other and then advance to the next cylinder (SIDES). It should be
noted here that there are several different CP/M Format layouts possible. For ORDER, there
are five different options in 22DISK: SIDES, CYLINDERS, EAGLE, COLUMBIA, or EVEN-ODD

Here are the 22DISK choices for those Parameters:

ORDER SIDES specifies that first one side then the other is written/read
before the cylinder number is advanced.

ORDER CYLINDERS specifies that all tracks on the first side are recorded
then all tracks on second side. Tracks on side 0 are written
from 0 up and side 1 down to 0.

ORDER EAGLE same as CYLINDERS except both sides start at zero or outermost
track.

ORDER COLUMBIA same as CYLINDERS except tracks are sequential from side
0 to side 1 ie. 0 - 79 for a 40 track disk.

ORDER EVEN-ODD means side 0 contains even-numbered tracks and side 1
contains odd-numbered tracks.


Here are the LIBDSK choices for those Parameters:

SIDES_ALT, /* Track n is cylinder C C0H0,C0H1,C1H0,C1H1,......*/
SIDES_OUTBACK, /* Tracks go (head 0) 0,1,2,3,...37,38,39, then
(head 1) 39,38,37,...,2,1,0 */
SIDES_OUTOUT, /* Tracks go (head 0) 0,1,2,3,...37,38,39, then
(head 1) 0,1,2,3,...37,38,39 */


10. COMPLEMENT is rare. Generally, if a diskette appears to be formatted with values of 1A
instead of E5, the data on the diskette is complemented.

11. Last resort for information will require a memory dump from F200 hex through FFFF to
provide all the DBP information as hex bytes. It will be necessary to dig through 3584 (E00)
bytes of data to locate the DPB information. Most systems follow the layout shown below.


(Hex values starting in memory at Fxxx)
RPT: (word) total # of logical 128-byte sectors/track
BSH: (byte) data allocation block shift factor,
determined by data block allocation size
1k=3 2k=4 4k=5 8k=6 16k=7
BLM: (byte) data allocation block mask (2**[BSH-1])
1k=7 2k=15 4k=31 8k=63 16k=127
EXM: (byte) extent mask, determined by the data block
allocation size and the number of disk blocks
1k=0 2k=1 4k=3 8k=7 16k=15 if DSM < 256
1k=n 2k=0 4k=1 8k=3 16k=7 if DSM > 256
DSM: (word) disk size in blocks-1; determines the total
storage capacity of the disk size
DRM: (word) directory size-1; determines the total number
directory entries that can be stored on this
drive. DRM: = ((# dir entries) / 4) -1
AL0: (byte) alloc0 (1100 0000) 2 blocks/dir
(1000 0000) 1 block/dir
AL1: (byte) alloc1 (0000 0000)
Note that AL0: and AL1: are taken together
as a single sixteen-bit mask for the number
of blocks of directory allocation.
(1100 0000 0000 0000) 2 blocks/dir
(1000 0000 0000 0000) 1 block/dir
CKS: (word) directory check vector size
fixed media: CKS = 0
removable media: CKS = (DRM + 1)/4
OFF/SOFF: (word) # of reserved system tracks or sectors (offset)
at the beginning of the (logical) disk.
Usually the directory begins at the first
sector of the track defined by this number.


By formatting a disk the number of tracks can be determined, which will give the first byte to
look for. The SPT will be followed by 00 and the value for BSH and BLM will be the third and
fourth bytes.

BSH and BLM will be one of the following Hex values:

BSH 3 or 4 or 5 or 6 or 7
BLM 7 or 0F or 1F or 3F or 7F

The above information should be fairly easily to locate.


Larry
Last edited by lkraemer on 2017-02-11 14:21, edited 1 time in total.
lkraemer
 
Posts: 175
Joined: 2011-02-09 05:02

Re: [HOWTO] - Access CP/M Floppy's via libdsk & cpmtools

Postby lkraemer » 2014-03-11 01:18

For those folks still using their Radio Shack Model 4 or 4P, I've attached the Montezuma Micro CP/M Version 2.31 Disk Definitions
I created (and submitted) for 22DISK. I've also updated the Definitions with those for LIBDSK & CPMTOOLS (03/11/2014).

The ones marked as #NOT TESTED were not verified, as I don't have a 96 tpi 5.25" Floppy Drive.

#22DISK CP/M Disk Definitions
BEGIN TRSG TRS-80 Model 4,4P Montezuma System 170K - SSDD 48 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 40 SIDES 1 SECTORS 18,256
SIDE1 0 1,3,5,7,9,11,13,15,17,2,4,6,8,10,12,14,16,18
BSH 4 BLM 15 EXM 1 DSM 84 DRM 127 AL0 0C0H AL1 0 OFS 2
END

#CPMTOOLS CP/M Disk Definitions
#diskdef trsg
# seclen 256
# tracks 40
# sectrk 18
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 2
# os 2.2
#end

#LIBDSK CP/M Disk Definitions
#[trsg]
#description = TRS-80 Model 4,4P Montezuma System 170K - SSDD 48 tpi 5.25"
#cylinders = 40
#heads = 1
#sectors = 18
#secbase = 1
#secsize = 256
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

BEGIN TRSH TRS-80 Model 4,4P Montezuma Data 200K - SSDD 48 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 40 SIDES 1 SECTORS 10,512
SIDE1 0 1,3,5,7,9,2,4,6,8,10
BSH 4 BLM 15 EXM 1 DSM 99 DRM 127 AL0 0C0H AL1 0 OFS 0
END

#diskdef trsh
# seclen 512
# tracks 40
# sectrk 10
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 0
# os 2.2
#end

#[trsh]
#description = TRS-80 Model 4,4P Montezuma Data 200K - SSDD 48 tpi 5.25"
#sides=alt
#cylinders = 40
#heads = 1
#sectors = 10
#secbase = 1
#secsize = 512
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

BEGIN TRSI TRS-80 Model 4,4P Montezuma System 350K - DSDD 48 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 40 SIDES 2 SECTORS 18,256
SIDE1 0 1,3,5,7,9,11,13,15,17,2,4,6,8,10,12,14,16,18
SIDE2 1 1,3,5,7,9,11,13,15,17,2,4,6,8,10,12,14,16,18
ORDER EAGLE
BSH 4 BLM 15 EXM 1 DSM 174 DRM 127 AL0 0C0H AL1 0 OFS 2
END

#diskdef trsi
# seclen 256
# tracks 80
# sides outout
# sectrk 18
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 2
# os 2.2
#end

#[trsi]
#description = TRS-80 Model 4,4P Montezuma System 350K - DSDD 48 tpi 5.25"
#sides=alt
#cylinders = 40
#heads = 2
#sectors = 18
#secbase = 1
#secsize = 256
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

BEGIN TRSJ TRS-80 Model 4,4P Montezuma Data 400K - DSDD 48 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 40 SIDES 2 SECTORS 10,512
SIDE1 0 1,3,5,7,9,2,4,6,8,10
SIDE2 1 1,3,5,7,9,2,4,6,8,10
ORDER EAGLE
BSH 4 BLM 15 EXM 1 DSM 199 DRM 127 AL0 0C0H AL1 0 OFS 0
END

#diskdef trsj
# seclen 512
# tracks 80
# sides outout
# sectrk 10
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 0
# os 2.2
#end

#[trsj]
#description = TRS-80 Model 4,4P Montezuma Data 400K - DSDD 48 tpi 5.25"
#sides=outout
#cylinders = 40
#heads = 2
#sectors = 10
#secbase = 1
#secsize = 512
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

#NOT TESTED
BEGIN TRSK TRS-80 Model 4,4P Montezuma System 350K - SSDD 96 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 80 SIDES 1 SECTORS 18,256
SIDE1 0 1,3,5,7,9,11,13,15,17,2,4,6,8,10,12,14,16,18
BSH 4 BLM 15 EXM 1 DSM 174 DRM 127 AL0 0C0H AL1 0 OFS 2
END

#diskdef trsk
# seclen 256
# tracks 80
# sectrk 18
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 2
# os 2.2
#end

#[trsk]
#description = TRS-80 Model 4,4P Montezuma System 350K - SSDD 96 tpi 5.25"
#cylinders = 80
#heads = 1
#sectors = 18
#secbase = 1
#secsize = 256
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

#NOT TESTED
BEGIN TRSL TRS-80 Model 4,4P Montezuma Data 400K - SSDD 96 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 80 SIDES 1 SECTORS 10,512
SIDE1 0 1,3,5,7,9,2,4,6,8,10
BSH 4 BLM 15 EXM 1 DSM 199 DRM 127 AL0 0C0H AL1 0 OFS 0
END

#diskdef trsl
# seclen 512
# tracks 80
# sectrk 10
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 0
# os 2.2
#end

#[trsl]
#description = TRS-80 Model 4,4P Montezuma Data 400K - SSDD 96 tpi 5.25"
#cylinders = 80
#heads = 1
#sectors = 10
#secbase = 1
#secsize = 512
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

#NOT TESTED
BEGIN TRSM TRS-80 Model 4,4P Montezuma System 710K - DSDD 96 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 80 SIDES 2 SECTORS 18,256
SIDE1 0 1,3,5,7,9,11,13,15,17,2,4,6,8,10,12,14,16,18
SIDE2 1 1,3,5,7,9,11,13,15,17,2,4,6,8,10,12,14,16,18
ORDER SIDES
BSH 4 BLM 15 EXM 0 DSM 354 DRM 127 AL0 0C0H AL1 0 OFS 2
END

#diskdef trsm
# seclen 256
# tracks 160
# sides alt
# sectrk 18
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 2
# os 2.2
#end

#[trsm]
#description = TRS-80 Model 4,4P Montezuma System 710K - DSDD 96 tpi 5.25"
#sides=alt
#cylinders = 80
#heads = 2
#sectors = 18
#secbase = 1
#secsize = 256
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

#NOT TESTED
BEGIN TRSN TRS-80 Model 4,4P Montezuma Data 800K - DSDD 96 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 80 SIDES 2 SECTORS 10,512
SIDE1 0 1,3,5,7,9,2,4,6,8,10
SIDE2 1 1,3,5,7,9,2,4,6,8,10
ORDER SIDES
BSH 4 BLM 15 EXM 0 DSM 399 DRM 127 AL0 0C0H AL1 0 OFS 0
END

#diskdef trsn
# seclen 512
# tracks 160
# sides alt
# sectrk 10
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 0
# os 2.2
#end

#[trsn]
#description = TRS-80 Model 4,4P Montezuma Data 800K - DSDD 96 tpi 5.25"
#sides=alt
#cylinders = 80
#heads = 2
#sectors = 10
#secbase = 1
#secsize = 512
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

BEGIN TRSO TRS-80 Model 4,4P Montezuma Extend System 190K - SSDD 48 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 40 SIDES 1 SECTORS 10,512
SIDE1 0 1,3,5,7,9,2,4,6,8,10
BSH 4 BLM 15 EXM 1 DSM 94 DRM 127 AL0 0C0H AL1 0 OFS 2
END

#diskdef trso
# seclen 512
# tracks 40
# sectrk 10
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 2
# os 2.2
#end

#[trso]
#description = TRS-80 Model 4,4P Montezuma Extend System 190K - SSDD 48 tpi 5.25"
#cylinders = 40
#heads = 1
#sectors = 10
#secbase = 1
#secsize = 512
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

BEGIN TRSP TRS-80 Model 4,4P Montezuma Extend System 390K - SSDD 48 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 40 SIDES 2 SECTORS 10,512
SIDE1 0 1,3,5,7,9,2,4,6,8,10
SIDE2 1 1,3,5,7,9,2,4,6,8,10
ORDER SIDES
BSH 4 BLM 15 EXM 1 DSM 194 DRM 127 AL0 0C0H AL1 0 OFS 2
END

#diskdef trsp
# seclen 512
# tracks 80
# sides alt
# sectrk 10
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 2
# os 2.2
#end

#[trsp]
#description = TRS-80 Model 4,4P Montezuma Extend System 390K - SSDD 48 tpi 5.25"
#sides=alt
#cylinders = 40
#heads = 2
#sectors = 10
#secbase = 1
#secsize = 512
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

#NOT TESTED
BEGIN TRSQ TRS-80 Model 4,4P Montezuma Extend System 390K - SSDD 96 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 80 SIDES 1 SECTORS 10,512
SIDE1 0 1,3,5,7,9,2,4,6,8,10
BSH 4 BLM 15 EXM 0 DSM 194 DRM 127 AL0 0C0H AL1 0 OFS 2
END

#diskdef trsq
# seclen 512
# tracks 80
# sectrk 10
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 2
# os 2.2
#end

#[trsq]
#description = TRS-80 Model 4,4P Montezuma Extend System 390K - SSDD 96 tpi 5.25"
#cylinders = 80
#heads = 1
#sectors = 10
#secbase = 1
#secsize = 512
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

#NOT TESTED
BEGIN TRSR TRS-80 Model 4,4P Montezuma Extend System 790K - DSDD 96 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 80 SIDES 2 SECTORS 10,512
SIDE1 0 1,3,5,7,9,2,4,6,8,10
SIDE2 1 1,3,5,7,9,2,4,6,8,10
ORDER SIDES
BSH 4 BLM 15 EXM 0 DSM 394 DRM 127 AL0 0C0H AL1 0 OFS 2
END

#diskdef trsr
# seclen 512
# tracks 160
# sides alt
# sectrk 10
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 2
# os 2.2
#end

#[trsr]
#description = TRS-80 Model 4,4P Montezuma Extend System 790K - DSDD 96 tpi 5.25"
#sides=alt
#cylinders = 80
#heads = 2
#sectors = 10
#secbase = 1
#secsize = 512
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

BEGIN TRSS TRS-80 Model 4,4P Montezuma Super Data 220K - SSDD 48 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 40 SIDES 1 SECTORS 6,1024
SIDE1 0 1,3,5,2,4,6
BSH 4 BLM 15 EXM 1 DSM 109 DRM 127 AL0 0C0H AL1 0 OFS 0
END

#diskdef trss
# seclen 1024
# tracks 40
# sectrk 6
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 0
# os 2.2
#end

#[trss]
#description = TRS-80 Model 4,4P Montezuma Super Data 220K - SSDD 48 tpi 5.25"
#cylinders = 40
#heads = 1
#sectors = 6
#secbase = 1
#secsize = 1024
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

BEGIN TRST TRS-80 Model 4,4P Montezuma Super Data 440K - DSDD 48 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 40 SIDES 2 SECTORS 6,1024
SIDE1 0 1,3,5,2,4,6
SIDE2 1 1,3,5,2,4,6
ORDER EAGLE
BSH 4 BLM 15 EXM 1 DSM 219 DRM 127 AL0 0C0H AL1 0 OFS 0
END

#diskdef trst
# seclen 1024
# tracks 80
# sides outout
# sectrk 6
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 0
# os 2.2
#end

#[trst]
#description = TRS-80 Model 4,4P Montezuma Super Data 440K - DSDD 48 tpi 5.25"
#sides=outout
#cylinders = 40
#heads = 2
#sectors = 6
#secbase = 1
#secsize = 1024
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

#NOT TESTED
BEGIN TRSU TRS-80 Model 4,4P Montezuma Super Data 440K - SSDD 96 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 80 SIDES 1 SECTORS 6,1024
SIDE1 0 1,3,5,2,4,6
BSH 4 BLM 15 EXM 1 DSM 219 DRM 127 AL0 0C0H AL1 0 OFS 0
END

#diskdef trsu
# seclen 1024
# tracks 80
# sectrk 6
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 0
# os 2.2
#end

#[trsu]
#description = TRS-80 Model 4,4P Montezuma Super Data 440K - SSDD 96 tpi 5.25"
#cylinders = 80
#heads = 1
#sectors = 6
#secbase = 1
#secsize = 1024
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

#NOT TESTED
BEGIN TRSV TRS-80 Model 4,4P Montezuma Super Data 880K - DSDD 96 tpi 5.25"
DENSITY MFM, LOW
CYLINDERS 80 SIDES 2 SECTORS 6,1024
SIDE1 0 1,3,5,2,4,6
SIDE2 1 1,3,5,2,4,6
ORDER SIDES
BSH 4 BLM 15 EXM 0 DSM 439 DRM 127 AL0 0C0H AL1 0 OFS 0
END

#diskdef trsv
# seclen 1024
# tracks 160
# sides alt
# sectrk 6
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 0
# os 2.2
#end

#[trsv]
#description = TRS-80 Model 4,4P Montezuma Super Data 880K - DSDD 96 tpi 5.25"
#sides=alt
#cylinders = 80
#heads = 2
#sectors = 6
#secbase = 1
#secsize = 1024
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y

BEGIN TRSW TRS-80 Model 4,4P Montezuma System 400K - SSDD 96 tpi 3.5"
DENSITY MFM, LOW
CYLINDERS 80 SIDES 1 SECTORS 10,512
SIDE1 0 1,3,5,7,9,2,4,6,8,10
BSH 4 BLM 15 EXM 1 DSM 199 DRM 127 AL0 0C0H AL1 0 OFS 0
END

#diskdef trsw
# seclen 512
# tracks 80
# sectrk 10
# blocksize 2048
# maxdir 128
# datarate DD
# fm NO
# skew 2
# boottrk 0
# os 2.2
#end

#[trsw]
#description = TRS-80 Model 4,4P Montezuma System 400K - SSDD 96 tpi 3.5"
#cylinders = 80
#heads = 1
#sectors = 10
#secbase = 1
#secsize = 512
#datarate = DD
#rwgap = 12
#fmtgap = 23
#fm = N
#multitrack = N
#skipdeleted = Y


Larry
Last edited by lkraemer on 2014-08-13 13:41, edited 4 times in total.
lkraemer
 
Posts: 175
Joined: 2011-02-09 05:02

Re: [HOWTO] - Access CP/M Floppy's via libdsk & cpmtools

Postby lkraemer » 2014-03-11 12:46

LIBDSK - SUPPORTS

Disk image types supported:

remote : Remote LibDsk instance
...........libdsk server at the far end of a serial connection
...........Remote LibDsk server, most likely at the other end of a serial line.
rcpmfs : Reverse CP/MFS driver
...........Host directory presented as a CP/M filesystem
...........Reverse CP/M filesystem. A directory is made to appear as a CP/M disk. This is an experimental
...........system and should be approached with caution.
floppy : Linux floppy driver
...........Host system's floppy drive (under Linux, DOS, or Windows).
dsk : CPCEMU .DSK driver
...........Disc image in the DSK format used by CPCEMU. The format of a .DSK file is described in the CPCEMU documentation.
edsk : Extended .DSK driver
...........Disc image in the extended CPCEMU DSK format.
apridisk : APRIDISK file driver
...........Disc image in the format used by the ApriDisk utility. The format is described in apridisk.html.
qm : CopyQM file driver
...........Disc images created by Sydex's CopyQM. This is a read-only driver.
tele : TeleDisk file driver
...........Disc images created by Sydex's TeleDisk. This is a read-only driver.
ydsk : YAZE YDSK driver
...........Disc image format used by the yaze and yaze-ag CP/M emulators.
raw : Raw file driver
...........Raw disc image - as produced by "dd if=/dev/fd0 of=image"
...........On systems other than Linux, DOS or Windows, this is also used to access the host system's floppy drive.
myz80 : MYZ80 hard drive driver
...........MYZ80 hard drive image, which is nearly the same as "raw" but has a 256 byte header.
simh : SIMH disc image driver
nanowasp : NanoWasp image file driver
...........Disc image in the 400k Microbee format used by the NanoWasp emulator. This is similar to "raw", but the
...........tracks are stored in a different order. LibDsk also applies a sector skew so that the sectors are
...........read/written in the logical order. Strictly speaking, it should not do this (when libdsk is used
...........with cpmtools, cpmtools is the one that does the skewing) but cpmtools cannot handle the skewing
...........scheme used by the Microbee format.
logical : Raw file logical sector order
...........Raw disc image in logical filesystem order. Previous versions of LibDsk could generate such
...........images (for example, by using the now-deprecated-logical option to dsktrans) but couldn't then write
...........them back or use them in emulators.
cfi : CFI file driver
...........Compressed floppy image, as produced by FDCOPY.COM under DOS. Its format is described in cfi.html.

LibDsk is a library that attempts to create uniform functions for accessing:

* Floppy drives, under Linux, Windows and MSDOS;
* Raw "dd" disc images (including floppy drives under other Unixes);
* .DSK files (as used by CPCEMU, JOYCE, XZX, etc.)
* MYZ80 hard drive images (as used by MYZ80 and JOYCE).
* Various other disc image formats which this margin is too small to enumerate.


LIBDSK has drivers for:
Raw files (including /dev/fdn).
Raw files, rearranged into logical filesystem order.
.DSK files, as used in CPCEMU, JOYCE and other Sinclair/Amstrad emulators.
MYZ80 hard drive image files.
NanoWasp floppy image files.
.CFI (Compressed Floppy Image) files, as created by FDCOPY.COM under DOS.
The Linux floppy drive (supports CPC System and Data formats, which the standard "Raw file" driver does not).
The Windows 3.x/95/98/ME/NT/2000 floppy drive.
The DOS floppy drive (via the PC BIOS).
CopyQM files (read-only)
TeleDisk files (read-only)
APRIDISK image files
The experimental LDBS format
rcpmfs - a backend that makes a Unix/Windows directory appear to be a CP/M disc image.
Another instance of LibDsk over a serial line.


LIBDSK also has the following default CP/M Floppy definitions included.
Code: Select all
   pcw180     : PCW / IBM 180k
   cpcsys     : CPC System
   cpcdata    : CPC Data
   pcw720     : PCW / IBM 720k
   pcw1440    : PcW16 / IBM 1440k
   ibm160     : IBM 160k (CP/M-86 / DOSPLUS)
   ibm320     : IBM 320k (CP/M-86 / DOSPLUS)
   ibm360     : IBM 360k (CP/M-86 / DOSPLUS)
   ibm720     : IBM 720k (144FEAT)
   ibm1200    : IBM 1.2M (144FEAT)
   ibm1440    : IBM 1.4M (144FEAT)
   acorn160   : Acorn 160k
   acorn320   : Acorn 320k
   acorn640   : Acorn 640k
   acorn800   : Acorn 800k
   acorn1600  : Acorn 1600k
   pcw800     : PCW 800k
   pcw200     : PCW 200k
   bbc100     : BBC 100k
   bbc200     : BBC 200k
   mbee400    : Microbee 400k
   mgt800     : MGT 800k
   trdos640   : TR-DOS 640k
   ampro200   : Ampro 40 track single-sided
   ampro400d  : Ampro 40 track double-sided
   ampro400s  : Ampro 80 track single-sided
   ampro800   : Ampro 80 track double-sided
   myz80      : MYZ80 8Mb
   pcpm320    : IBM 320k (CP/M-86 / DOSPLUS)

Additional CP/M Disk Definitions can be added in /home/user/.libdskrc


DSKTRANS — Copy from one floppy or image file to another

SYNOPSIS:
dsktrans [-itype TYPE] [-otype TYPE] [-iside SIDE] [-oside SIDE] [-icomp COMP] [-ocomp COMP]
[-idstep] [-odstep] [-retry COUNT] [-format FMT] [-first CYLINDER] [-last CYLINDER]
[-comment TEXT] [-comment @FILE] [-md3] [-logical] [-apricot] [-pcdos] [-noformat] INPUT-IMAGE OUTPUT-IMAGE

dsktrans copies floppy discs or images, optionally converting image types. This is a high-level copy which assumes
that the disc has a straightforward geometry; all the tracks are assumed to have the same layout of sectors, and
interleave is not preserved.

To convert the imagedisk .imd images back to .img (raw - you can rename .raw to .img) use:
Code: Select all
dsktrans -otype raw -format sin2 ElwroG1.dsk ElwroG1.raw
dsktrans -otype raw -format amp1 AmprOrig.dsk AmprOrig.raw
cpmls -d -T raw,elwro -f elwro ElwroG1.img
cpmls -d -T raw,pcw720 -f elwro ElwroG1.img
cpmls -d -T edsk,elwro -f elwro ElwroG1.dsk


libdsk can also be used standalone to convert from a Cylinder/Head/Sector disk image (as used by, for example, VirtualBox)
to a dump in file system order:

dsktrans -itype raw -otype logical -format ibm1440 infile.vfd outfile.cpmfs
and back:
dsktrans -itype logical -otype raw -format ibm1440 infile.cpmfs outfile.vfd


dsktrans -otype floppy 720CPM86.IMG /dev/fd0

dsktrans /dev/fd0 filename.ufi -otype raw
cpmcp -f amstrad filename.ufi 0:filename .

dsktrans -itype qm -otype raw input output
or even
dsktrans -itype qm -otype floppy input /dev/fd0



SAMdisk - SUPPORTS

The following containers types are supported for input:

EDSK - Extended disk image (Amstrad CPC, Spectrum +3, PC)
MGT - MGT +D/Disciple/SAM (Sinclair Spectrum / SAM Coupé)
SAD - SAm Disk (SAM Coupé)
SBT - Sam BooTable disk (SAM Coupé)
SDF - Sam Disk Format (SAM Coupé)
CPM - Pro-DOS CP/M (SAM Coupé)
TD0 - Sydex TeleDisk (various)
RAW - KryoFlux stream format [IBM MFM and FM only].
SCP - SuperCard Pro stream format [IBM MFM and FM only].
DFI - DiscFerret stream format [IBM MFM and FM only].
IPF - Interchangeable Preservation Format [IBM MFM only]
DMK - David M Keil's disk format (mainly TRS-80)
IMD - ImageDisk utility image (various)
TRD - Beta128 disk for TR-DOS (Sinclair Spectrum)
FDI - Full Disk Image (Sinclair Spectrum, not Disk2FDI!)
OPD - OPus Discovery (Sinclair Spectrum)
MBD - MB-02+ Disk (Sinclair Spectrum)
UDI - Ultra Disk Image (Sinclair Spectrum)
SCL - Sinclair betadisk archive (Sinclair Spectrum)
DSK - Disk image (Amstrad CPC)
DSC - WinAPE disk image (Amstrad CPC)
CFI - Compressed Floppy Image (Amstrad)
BPB - FAT12/16 BIOS Parameter Block (MS-DOS, Atari ST)
MSA - Magic Shadow Archive (Atari ST)
D80 - Didaktik D80
D88 - Pasopeia D88 (NEC PC-xx)
D81 - Commodore 1581
D2M - Commodore CMD FD-2000
D4M - Commodore CMD FD-4000
LIF - Logical Interchange Format (Hewlett-Packard)
S24 - Sega System 24 (Arcade, 1.8M and 1.88M formats)
RAW - some raw sector dumps, identified by file size only

The following types are supported for output of new or modified disk images:

.DSK - Extended DSK flexible format
.MGT - Miles Gordon Technology +D/SAM (80/2/10/512)
.CPM - SAM Coupé Pro-DOS (80/2/9/512)
.TRD - Beta128 / TR-DOS (typically 80/2/16/256)
.FDI - Full Disk Image flexible format (no connection to Disk2FDI)
.OPD - Opus Discovery (typically 40/1/18/256)
.IMD - ImageDisk flexible format
.D81 - Commodore 1581 (80/2/10/512)
.D88 - Pasopeia D88 (NEC PC-xx) flexible format
.D2M - CMD FD-2000 (81/2/10/1024)
.LIF - HP Logical Interchange Format (77/2/16/256)
.RAW - Raw sector dump in suitable regular format

http://simonowen.com/samdisk/formats/


Is there a utility to convert the imagedisk .imd images back to .img raw?

Found the solution using simon owen's samdisk
Code: Select all
samdisk test.imd test.raw

rename .raw to .img and it even booted !!!

Another solution is to use ImageDisks IMDU
Code: Select all
IMDU file.img file.raw /E /B

If you want more information about the image use the following command:
Code: Select all
IMDU file.img file.raw /E /B /D > file-log.txt

Then read the file-log.txt document.

Larry
Last edited by lkraemer on 2017-01-26 02:12, edited 4 times in total.
lkraemer
 
Posts: 175
Joined: 2011-02-09 05:02

Re: [HOWTO] - Access CP/M Floppy's via libdsk & cpmtools

Postby lkraemer » 2014-03-25 14:12

LIBDSK

Usage Commands:
Code: Select all
dskscan
dsktrans
dskdump
dskform
dskid
dskutil

For more detailed information on the commands:
Code: Select all
man dskscan
man dsktrans
man dskdump
man dskform
man dskid
man dskutil


dskscan
Syntax:
dskscan {options} image
Options are:
-type <type> type of input disc image
-side <side> Force side 0 or side 1 of input
-retry <count> Set number of retries on error
-first <cyl> Start at specified cylinder
-last <cyl> Scan up to specified cylinder
-dstep Double-step
-xml Output as XML
-format Force a specified format name

Default type is autodetect.

eg: dskscan /dev/fd0
dskscan -xml /dev/fd1

Valid DEFAULT formats are:
pcw180 : PCW / IBM 180k
cpcsys : CPC System
cpcdata : CPC Data
pcw720 : PCW / IBM 720k
pcw1440 : PcW16 / IBM 1440k
ibm160 : IBM 160k (CP/M-86 / DOSPLUS)
ibm320 : IBM 320k (CP/M-86 / DOSPLUS)
pcpm320 : IBM 320k (CP/M-86 / DOSPLUS)
ibm360 : IBM 360k (DOSPLUS)
ibm720 : IBM 720k (144FEAT)
ibm1200 : IBM 1.2M (144FEAT)
ibm1440 : IBM 1.4M (144FEAT)
acorn160 : Acorn 160k
acorn320 : Acorn 320k
acorn640 : Acorn 640k
acorn800 : Acorn 800k
acorn1600 : Acorn 1600k
pcw800 : PCW 800k
pcw200 : PCW 200k
bbc100 : BBC 100k
bbc200 : BBC 200k
mbee400 : Microbee 400k
mgt800 : MGT 800k
trdos640 : TR-DOS 640k
myz80 : MYZ80 8Mb

Additional CP/M Floppy Disk definition can be added to your
/home/user/.libdskrc file.


/home/user/.libdskrc file permissions are:
Code: Select all
-rw-r--r-- 1 user user 152913 Mar 10 20:57 .libdskrc


/home/user/.libdskrc contains:
Code: Select all
# Anything after a semicolon or hash character is treated as a comment and ignored.
# Blank lines are also ignored.
#
# description=DESC The description of the format as shown by (for example) dskform–help.
# sides=TREATMENT How a double-sided disk is handled. This can either be alt
#       (sides alternate – used by most PC-hosted operating systems), outback (use side
#       0 tracks 0-79, then side 1 tracks 79-0 – used by 144FEAT CP/M disks), or outout
#       (use side 0 tracks 0-79, then side 1 tracks 0-79 – used by some Acorn formats).
#       If the disk is single-sided, this parameter can be omitted.
# cylinders=COUNT Sets the number of cylinders (usually 40 or 80).
# heads=COUNT Sets the number of heads (usually 1 or 2 for single- or double- sided).
# sectors=COUNT Sets the number of sectors per track.
# secbase=NUMBER Sets the first sector number on a track. Usually 1; some Acorn
#         formats use 0.
# secsize=COUNT Sets the size of a sector in bytes. This should be a power of 2.
# datarate=VALUE Sets the rate at which the disk should be accessed. This is one of
#          HD, DD, SD or ED.
# rwgap=VALUE Sets the read/write gap.
# fmtgap=VALUE Sets the format gap.
# fm=Y or N Sets the recording mode - Y for FM, N for MFM.
# multitrack=Y or N Sets multitrack mode.
# skipdeleted=Y or N Sets whether to skip deleted data.
#
#libdskrc example:
# This is FMT_800K as a libdskrc entry
#[xcf2dd]
#Description = 800k XCF2DD format
#Sides = Alt
#Cylinders = 80
#Heads = 2
#Sectors = 10
#SecBase = 1
#SecSize = 512
#DataRate = SD
#RWGap = 12
#FmtGap = 23
#[xcf2]
#Description = 200k XCF2 format
#Cylinders = 40
#
#
[ibm3740]
description = IBM3740 SS SD 77T 8" 26x128 b/s
cylinders = 77
heads = 1
sectors = 26
secbase = 1
secsize = 512
datarate = SD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y
 
#
# According to the printed documentation I have for Version 1.39 of 22DISK
#
#        SIDES specifies that first one side then the other is written/read
#              before the cylinder number is advanced.
#
#        CYLINDERS specifies that all tracks on the first side are recorded
#              then all tracks on second side.  Tracks on side 0 are written
#              from 0 up and side 1 down to 0.
#
#        EAGLE same as CYLINDERS except both sides start at zero or outermost
#              track.
#
#        COLUMBIA same as CYLINDERS except tracks are sequential from side
#              0 to side 1 ie. 0 - 79 for a 40 track disk.
#
#        EVEN-ODD means side 0 contains even-numbered tracks and side 1
#              contains odd-numbered tracks.
#
#
[kpii]
description = Kaypro II/2 - SSDD 48 tpi 5.25"
cylinders = 40
heads = 1
sectors = 10
secbase = 0
secsize = 512
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y

[kpiv]
description = Kaypro 2X/4/10 - DSDD 48 tpi 5.25"
cylinders = 80
heads = 2
sectors = 10
secbase = 0
secsize = 512
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y

[amp1]
description = Ampro - SSDD 48 tpi 5.25"
cylinders = 40
heads = 1
sectors = 10
secbase = 1
secsize = 512
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y

[amp2]
description = Ampro - DSDD 48 tpi 5.25"
sides=alt
cylinders = 40
heads = 2
sectors = 10
secbase = 17
secsize = 512
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y

[amp3]
description = Ampro - SSDD 96 tpi 5.25"
cylinders = 80
heads = 1
sectors = 5
secbase = 17
secsize = 1024
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y
 
[amp4]
description = Ampro - DSDD 96 tpi 5.25"
sides=alt
cylinders = 80
heads = 2
sectors = 5
secbase = 17
secsize = 1024
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y
 
[amp5]
description = Ampro - SSDD 96 tpi 3.5"
cylinders = 80
heads = 1
sectors = 5
secbase = 1
secsize = 1024
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y

[amp6]
description = Ampro - DSDD 96 tpi 3.5"
sides=alt
cylinders = 80
heads = 2
sectors = 5
secbase = 17
secsize = 1024
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y

[ampro800]
description = Ampro800 - DSDD 96 tpi 3.5"
sides=alt
sectors = 5
secbase = 17
secsize = 1024
datarate = DD
rwgap = 12
fmtgap = 23
fm = N
multitrack = N
skipdeleted = Y


LIBDSK DOCUMENTATION

Detailed LibDsk Documentation is located at:
/home/user/your/path/to/libdsk-1.3.5/doc/


Enjoy.

Larry
lkraemer
 
Posts: 175
Joined: 2011-02-09 05:02

Re: [HOWTO] - Access CP/M Floppy's via libdsk & cpmtools

Postby lkraemer » 2016-01-11 00:29

UPDATE 01-25-2017

The current version of cpmtools is 2.20 and is located at: http://www.moria.de/~michael/cpmtools/f ... .20.tar.gz
The current version of libdsk is 1.4.2 and is located at: http://www.seasip.info/Unix/LibDsk/libdsk-1.4.2.tar.gz
Note that libdsk now requires lyx and lyx-common to be installed.

You may have built cpmtools (without libdsk) or you may have built cpmtools with libdsk, to allow more disk image access possibilities.

In your searches for CP/M images you've likely stumbled on Dave Dunfield's site with several different System Images in .IMD format at:
http://www.classiccmp.org/dunfield/img54306/system.htm

Let's access a few of these IMD files with cpmtools (with libdsk).

I've selected one of the CP/M files at random, to test cpmtools and libdsk:

http://www.classiccmp.org/dunfield/img54306/d/zorba.zip

The first thing to do is download some .ZIP files, extract their contents in separate subdirectories, and read the included README.TXT

The first Windows command I use in XP is:
Code: Select all
IMDU ZORBA1.IMD > ZORBA1.TXT

which gives me a lot of detail about the .IMD image:
IMageDisk Utility 1.18 / Mar 07 2012
IMD 1.01: 3/08/2005 11:16:41

Zorba Personal Computer

System Disk (BIOS version 1.7)A

CP/M 2.2 CP2-865-04553

CBASIC CBA-865-04553

Copyright 1981 by Digital Research, Inc.

0/0 250 kbps DD 10x512
80 tracks(40/40), 800 sectors (465 Compressed)


This information tells me it's a 40 Track Image with 2 Heads, and with 10 Sectors of 512 Bytes. You will need this
information to select the proper definition for cpmtools and libdsk.

ZORBA.ZIP contains:
ZORBA1.IMD, ZORBA2.IMD, ZORBA3.IMD, ZORBA4.IMD, ZORBA5.IMD & README.TXT

Next, you need to create the .RAW image files of all .IMD files in Windows or in DOSBOX. I use IMDU:
Code: Select all
IMDU ZORBA1.IMD ZORBA1.RAW /E /B
IMDU ZORBA2.IMD ZORBA2.RAW /E /B
IMDU ZORBA3.IMD ZORBA3.RAW /E /B
IMDU ZORBA4.IMD ZORBA4.RAW /E /B
IMDU ZORBA5.IMD ZORBA5.RAW /E /B

OR
Code: Select all
IMDU ZORBA1.IMD ZORBA1.RAW /E /B /D > ZORBA1.TXT
IMDU ZORBA2.IMD ZORBA2.RAW /E /B /D > ZORBA2.TXT
IMDU ZORBA3.IMD ZORBA3.RAW /E /B /D > ZORBA3.TXT
IMDU ZORBA4.IMD ZORBA4.RAW /E /B /D > ZORBA4.TXT
IMDU ZORBA5.IMD ZORBA5.RAW /E /B /D > ZORBA5.TXT


To create the .RAW images for accessing with cpmtools, or cpmtools with libdsk.

The zorba definitions are:
Code: Select all
# ZOR1  Zorba - DSDD 48 tpi 5.25" - 512 x 10
diskdef zor1
  seclen 512
  tracks 40
  sectrk 20
  blocksize 2048
  maxdir 64
  skew 1
  offset 10240
  boottrk 0
  os 2.2
end

# libdsk data below
[zor1]
description = ZOR1  Zorba - DSDD 48 tpi 5.25" - 512 x 10
#sides = extsurface
cylinders = 80
heads = 2
secsize = 512
sectors = 10
secbase = 1
datarate = DD


# ZOR2  Zorba - DSDD 96 tpi 5.25" - 512 x 10
diskdef zor2
  seclen 512
  tracks 80
  sectrk 20
  blocksize 4096
  maxdir 128
  skew 1
  offset 10240
  boottrk 0
  os 2.2
end

# libdsk data below
[zor2]
description = ZOR2  Zorba - DSDD 96 tpi 5.25" - 512 x 10
#sides = extsurface
cylinders = 160
heads = 2
secsize = 512
sectors = 10
secbase = 1
datarate = DD


The ZOR1 definition is the one that fits the IMDU Imagedisk information.


cpmtools (without libdsk) commands
Code: Select all
man cpmls
man cpmcp
cpmls -f zor1 -d ZORBA1.RAW


ASM COM : DDT COM : ED COM : LOAD COM
MOVCPM COM : PIP COM : STAT COM : SUBMIT COM
XSUB COM : DUMP COM : M80 COM : L80 COM
CREF80 COM : LIB80 COM : CBAS2 COM : CRUN2 COM
XREF COM : SGEN COM : PATCH COM : SETUP COM
FORMAT COM : TRACKRD COM : RELOAD COM : VT52 KEY
TALK COM


Code: Select all
cpmcp -f zor1 ZORBA1.RAW 0:*.COM /home/larry/IMDs/zorba
cpmcp -f zor1 ZORBA1.RAW 0:vt52.key /home/larry/IMDs/zorba
more vt52.key


cpmtools with libdsk commands
Code: Select all
cpmls -f zor1 -T raw,zor1 -d ZORBA1.RAW
cpmcp -f zor1 -T raw,zor1 ZORBA1.RAW 0:*.COM /home/larry/IMDs/zorba
cpmcp -f zor1 -T raw,zor1 ZORBA1.RAW 0:vt52.key /home/larry/IMDs/zorba
more vt52.key
cpmcp -f zor1 -T raw,zor1 ZORBA1.RAW /home/larry/IMDs/zorba/*.COM 0:


So, now you can easily copy files to and from your .RAW Images using cpmtools (or cpmtools with libdsk).

But, maybe you also need to create a new .IMD from the .RAW image.

From DOSBox, the BIN2IMD utility will create an .IMD of a .RAW Image.

Code: Select all
BIN2IMD input-file output-image [option-file] [options]

BIN2IMD X.RAW X.IMD DM=2 N=80 SS=512 SM=1-8 /2


Where the Options are:
opts: /1 - 1-sided output
/2 - 2-sided output
/C - write Compressed sectors
/U - write Uncompressed sectors
/V[0|1] - Verbose output
C=text | @file - image Comment
N=#cylinders - set Number of output cylinders
DM[s]=0-5 - track Data Mode
SS[s]=128-8192 - track Sector Size
SM[s]=n[,n-n][n.#] - track Sector numbering Map
CM[s]=n[,n-n][n.#] - track/sector Cylinder Map
HM[s]=n[,n-n][n.#] - track/sector Head Map

and

DM= sets the Data Mode, which must be one of:
0 = 500 kbps FM \ Note: kbps indicates transfer
1 = 300 kbps FM > rate, not the data rate,
2 = 250 kbps FM / which is 1/2 for FM
3 = 500 kbps MFM encoding.
4 = 300 kbps MFM
5 = 250 kbps MFM

SS= sets the Sector Size, and must be one of:

128, 256, 512, 1024, 2048, 4096 or 8192.

See: Imagedisk's IMD.TXT for more details.



REF:
https://virtuallyfun.superglobalmegacor ... ent-177828


Larry
lkraemer
 
Posts: 175
Joined: 2011-02-09 05:02

Re: [HOWTO] - Access CP/M Floppy's via libdsk & cpmtools

Postby lkraemer » 2017-09-19 11:49


UPDATE 09-19-2017


GETTING GARBAGE DIRECTORY LISTING??

If you have had trouble getting a directory listing, there are a few things that can be tried to get a valid directory listing.

Here is an example directory listing that is corrupt.

Code: Select all
cpmls -D -f als1 61KCPM3B.RAW


larry@debian:~/IMD-118/Alspa$ cpmls -D -f als1 61KCPM3B.RAW
Name Bytes Recs Attr update create
------------ ------ ------ ---- ----------------- -----------------
#6CO6.#P# 0K 0 R

User 3:

Name Bytes Recs Attr update create
------------ ------ ------ ---- ----------------- -----------------
M2,IX2.-IM 0K 0 R

User 14:

Name Bytes Recs Attr update create
------------ ------ ------ ---- ----------------- -----------------
'W2D!D.4M+ 0K 0 R
T~@L]8M.H> 0K 0 R
4 Files occupying 2K, 594K Free.


Looking at the output of the the imagedisk utilities, I see that the first track is 26 sectors x 128 bytes (3328 bytes), while the remaining
tracks are 8 sectors x 1024 bytes (622592 bytes). I used hexedit in Debian to locate the CP/M Directory listing. It was at 0x2D00
which is at 11520 decimal. With that information I can try two stanzas in my als1 definition to see if that works.

Code: Select all
imdu 61KCPM3B.IMD 61KCPM3B.RAW /B /E /D >> 61KCPM3B.TXT


IMageDisk Utility 1.18 / Mar 07 2012
IMD TD 1.4 8" HD MFM S-step, 1 sides ADV

Assuming 1:1 for Binary output
0/0 500 kbps SD 26x128 = 3328 bytes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
D DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5DE5
1/0 500 kbps DD 8x1024 = 8192 bytes
1 2 3 4 5 6 7 8
D D D D D D D D
2/0 1 6 3 8 5 2 7 4
D D D D D D D DE5
..
..
..
75/0 DE5 DE5 DE5 DE5 DE5 DE5 DE5 DE5
76/0 DE5 DE5 DE5 DE5 DE5 DE5 DE5 DE5 = 76*(8192) = 622592
77 tracks(77/0), 634 sectors (191 Compressed)


Original Definition
Code: Select all
# ALS1  Alspa - SSDD 8" - 1024 x 8
diskdef als1
  seclen 1024
  tracks 77
  sectrk 8
  blocksize 2048
  maxdir 128
  skew 1
  boottrk 2
  os 2.2
end


Modified Definition:
Code: Select all
# ALS1  Alspa - SSDD 8" - 1024 x 8
diskdef als1
  seclen 1024
  tracks 77
  sectrk 8
  blocksize 2048
  maxdir 128
  skew 1
  boottrk 0
#0x2D00 = 11520
  offset 11520
  os 2.2
end


I still get an error when I try to get a directory listing. So, I change back to my Original Definition.

There has to be another way to get the correct Directory listing, and then get the files extracted.
Maybe I can write the first track so that it matches the remaining 76 tracks and try to get a directory listing.
I know I won't be able to boot a floppy created from this file, but I want the files extracted, and don't need
to boot this created image.

So, I use dd to write a track 0 which will contain 8 sectors of 1024 bytes. This will become the
first track of the output file. The Linux command to do this is:

Code: Select all
dd if=/dev/zero of=test.raw count=8192 bs=1


That creates Track 0 which is now also 8192 bytes long. Then, I simply add the remainder of the data to
the "test.raw" file. That Linux command is:

Code: Select all
dd if=61KCPM3B.RAW skip=3328 count=622592 bs=1 seek=8192 of=test.raw conv=notrunc


I skip the first 3328 bytes of the input file (Track 0), then copy the remaining bytes ((1024 * 8)*76) OR 76 Tracks.
The Directory listing is now sane, and I can copy the files to a folder.

Code: Select all
cpmls -D -f als1 test.raw

OR
Code: Select all
cpmls -f als1 -T raw,als1 test.raw

OR
Code: Select all
cpmls -f als1 -T raw,als1 -D test.raw


Name Bytes Recs Attr update create
------------ ------ ------ ---- ----------------- -----------------
ASM .COM 8K 64
CPMTODEC.ASM 20K 151
CPMTODEC.COM 4K 30
CPMTODEC.HEX 8K 55
CPMTODEC.PRN 38K 300
D .COM 4K 20
DBASEAPP.OVR 4K 31
DBASEBRO.OVR 2K 11
DBASEJOI.OVR 2K 7
DBASEMAI.OVR 8K 55
DBASEMOD.OVR 4K 23
DBASEMSC.OVR 4K 27
DBASEMSG.COM 8K 62
DBASERPG.OVR 4K 25
DBASESRT.OVR 2K 11
DBASETTL.OVR 2K 8
DBASEUPD.OVR 2K 8
DDT .COM 6K 38
DECTOCPM.ASM 18K 141
DO .COM 18K 142
DU .COM 6K 48
DUMP .COM 4K 24
ED .COM 8K 52
FCOPY .COM 4K 29
FORM1K .COM 6K 37
INSTRUCT.BAK 10K 74
LISTDEC .ASM 10K 79
LISTDEC .COM 4K 17
LISTDEC .HEX 4K 23
LISTDEC .PRN 20K 157
LOAD .COM 2K 14
LST . 12K 82
M73A .COM 10K 76
MBASIC .COM 24K 188
PIP .COM 8K 58
PRINT .SUB 2K 3
STAT .COM 6K 41
SUBMIT .COM 2K 10
SYST1K .COM 2K 16
UNLOAD .COM 2K 6
VME .DEF 2K 1
WIRE .LST 8K 58
WIRE108 .ASC 2K 16
WM .COM 10K 76
WM .HLP 4K 21
WSMSGS .OVR 28K 218
WSOVLY1 .OVR 34K 266
WSVA .COM 16K 124
XSUB .COM 2K 6
ZIP .COM 30K 236
50 Files occupying 448K, 148K Free.


And it's now easy to copy the files to my created subdirectory.

Code: Select all
cpmcp -f als1 test.raw 0:*.* /home/larry/IMD-118/Alspa/61KCPM3B


Thanks.

Larry
lkraemer
 
Posts: 175
Joined: 2011-02-09 05:02


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable