Subversion Repositories SvarDOS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
54 mv_fox 1
/*
2
 * CD-ROM detection routines
3
 * Copyright (C) 2016 Mateusz Viste
4
 */
5
 
6
#include <dos.h>
7
#include "cdrom.h" /* include self for control */
8
 
9
/* returns 1 if drive drv is a valid CDROM, zero if not, negative if no MSCDEX (0=A:, etc) */
10
int cdrom_drivecheck(int drv) {
11
  union REGS r;
12
  r.x.ax = 0x150B;
13
  r.x.cx = drv;
14
  int86(0x2F, &r, &r);
15
  if (r.x.bx != 0xADAD) return(-1); /* look for the MSCDEX signature */
16
  if (r.x.ax == 0) return(0);
17
  return(1);
18
}
19
 
20
/* returns the identifier of the first CDROM drive (0=A:, etc), or a negative value on error */
21
int cdrom_findfirst(void) {
22
  int i;
23
  for (i = 2; i < 26; i++) { /* check drives from C to Z */
24
    int cdres = cdrom_drivecheck(i);
25
    if (cdres == 0) continue;
26
    if (cdres == 1) return(i);
27
    break;
28
  }
29
  return(-1);
30
}