$title ('MP/M II  V2.0  Disk System Reset')
disk$reset:
do;

$include (copyrt.lit)
/*
  Revised:
    14 Sept 81  by Thomas Rolander
*/

  declare start label;
  declare jmp$to$start structure (
    jmp$instr byte,
    jmp$location address ) data  (
    0C3H,
    .start-3);

  mon1:
    procedure (func,info) external;
      declare func byte;
      declare info address;
    end mon1;

  declare tbuff (1) byte external;

  /**************************************
   *                                    *
   *       B D O S   Externals          *
   *                                    *
   **************************************/

  reset$drives:
    procedure (drive$vector);
      declare drive$vector address;
      call mon1 (37,drive$vector);
    end reset$drives;

  /**************************************
   *                                    *
   *       X D O S   Externals          *
   *                                    *
   **************************************/

  terminate:
    procedure;
      call mon1 (143,0);
    end terminate;

  declare mask (16) address data (
    0000000000000001b,
    0000000000000010b,
    0000000000000100b,
    0000000000001000b,
    0000000000010000b,
    0000000000100000b,
    0000000001000000b,
    0000000010000000b,
    0000000100000000b,
    0000001000000000b,
    0000010000000000b,
    0000100000000000b,
    0001000000000000b,
    0010000000000000b,
    0100000000000000b,
    1000000000000000b );

  declare drive$mask address initial (0);
  declare i byte;

  /*
    Main Program
  */

start:
  do;
    i = 0;
    if tbuff(0) = 0 then
    do;
      drive$mask = 0ffffh;
    end;
    else
    do while (i:=i+1) <= tbuff(0);
      if (tbuff(i) >= 'A') and (tbuff(i) <= 'P') then
      do;
        drive$mask = drive$mask or mask(tbuff(i)-'A');
      end;
    end;
    call reset$drives (drive$mask);
    call terminate;
  end;

end disk$reset;
