home *** CD-ROM | disk | FTP | other *** search
- /* xalv.c - dump the CP/M disk allocation vector in binary */
- /* Version 1.2 1982/12/18 19:56 */
- /*
- Inspired by the assembly language routine ACTDIR in
- David E. Cortesi's INSIDE CP/M: A Guide for Users and Programmers,
- Holt, Rinehart and Winston, New York 1982, p. 239-241.
-
- C version:
-
- Copyright 1982 William G. Hutchison, Jr.
- P.O. Box 278
- Exton, PA 19341-0278
- U.S.A.
-
- CompuServe 70665,1307
-
-
-
-
- This program may be used freely for any non-commercial
- purpose, provided that the user does not remove or alter
- this notice or the copyright statement.
- Those who wish to sell or lease this program, or to
- incorporate it into a product for sale or lease, should
- apply to the author (above) for licensing information.
- This program is not covered by a warranty, either
- express or implied. The author shall not be responsible for
- any damages (including consequential) caused by reliance on
- the materials presented, including but not limited to
- typographical errors or arithmetic errors.
-
- This version is for C/80 Version 2 from Software Toolworks.
-
-
- */
-
- #include "c80def.h"
- #define uns unsigned
- #include "printf.c"
-
- #include "dpb.h"
- #include "fcb.h"
- static struct fcb *cpmfcb= 0x5C;
-
- #include "bdos.c"
- #define BITS_PER_BYTE 8
- #define LINE_BITS 48
- #define LEFT_BIT 0x80
- #define DEFAULT_DRIVE 25
- #define DISK_PARAMETERS 31
- #define GET_ALLOCATION_VECTOR 27
- #define SELECT_DRIVE 14
-
- main()
- {
- int drive;
- struct dpb *x;
- int b, bytes, k;
- char *v /* pointer to allocation vector */;
- char z /* one byte of allocation vector */;
-
- static char Version[]= "Version 1.2 1982/12/18 19:56";
- static char Notice[]= "Copyright 1982 William G. Hutchison, Jr.";
-
- printf("%s\n%s\n\n", Version, Notice);
-
- if ((drive= cpmfcb->drv) == 0)
- drive= bdos(DEFAULT_DRIVE, 0);
- else
- drive-- /* 1..26 => 0..25 */;
-
- bdos(SELECT_DRIVE, drive);
- v= bdos(GET_ALLOCATION_VECTOR, 0);
- x= bdos(DISK_PARAMETERS, 0);
-
- printf("Disk allocation vector for drive %c.\n", 'A'+drive);
-
- k= LINE_BITS;
- bytes= (x->dsm + BITS_PER_BYTE-1)/BITS_PER_BYTE;
- while (bytes-- > 0) {
- z= *v++;
- for (b= BITS_PER_BYTE; b > 0; b--) {
- printf("%c", '0'+ ((z & LEFT_BIT) != 0));
- z+= z /* z<<= 1 */;
- if (--k == 0) {
- printf("\n");
- k= LINE_BITS;
- }
- }
- }
- }