home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / pas_sdk1 / pas / subs / cdrom / mscdex.asm < prev    next >
Encoding:
Assembly Source File  |  1992-06-25  |  9.1 KB  |  624 lines

  1.     page 64, 131
  2.     title mscdex.asm - interface to mscdex interrupt 2F
  3.  
  4. ;    /*\
  5. ;    |*|    mscdex.asm
  6. ;    |*|    
  7. ;    |*|    routines for c-interface to mscdex
  8. ;    |*|    support for those functions defined in mscdex v(2.
  9. ;    |*|
  10. ;    |*|    Copyright (c) 1992, Media Vision, Inc.  All Rights Reserved
  11. ;    |*|
  12. ;    \*/
  13.  
  14.     .xlist 
  15.     include model.inc
  16.     include masm.inc
  17.     include common.inc
  18.     include binary.inc
  19.     .list
  20.  
  21. if MODELSIZE eq 0
  22.     .code
  23. else
  24.     .data
  25. endif
  26.  
  27. ;; this holds the last value returned with carry set from int 2F
  28.     public lasterror
  29. lasterror    dw 0
  30.  
  31.     .code
  32.  
  33. ;    /*\
  34. ;    |*|    int ismscdex(void) 
  35. ;    |*|    
  36. ;    |*|    Entry:    none
  37. ;    |*|
  38. ;    |*|    Exit:    return TRUE (not zero) if mscdex exists, 
  39. ;    |*|        else FALSE (zero) 
  40. ;    |*|
  41. ;    \*/
  42.  
  43.     public    ismscdex
  44. ismscdex    proc
  45.     push bp
  46.     mov bp, sp
  47.  
  48.     mov ax, 1500h            ; is function 15h available?
  49.     xor bx, bx
  50.     int 2Fh
  51.  
  52.     xor ax, ax            ; ready to return 0
  53.  
  54.     or bx, bx            ; does mscdex report available?
  55.     jz done                ; not here, return 0
  56.  
  57.     inc ax                ; yes here, return 1
  58.  
  59. done:
  60.     pop bp
  61.     ret
  62. ismscdex    endp
  63.  
  64.  
  65. ;    /*\
  66. ;    |*|    int getnumcdroms(void)
  67. ;    |*|
  68. ;    |*|    Entry:    none
  69. ;    |*|
  70. ;    |*|    Exit:    return total count of cdrom drives in system 
  71. ;    |*|
  72. ;    \*/
  73.  
  74.     public    getnumcdroms
  75. getnumcdroms    proc
  76.     push bp
  77.     mov bp, sp
  78.  
  79.     mov ax, 1500h
  80.     xor bx, bx
  81.     int 2Fh
  82.  
  83.     mov ax, bx
  84.     pop bp
  85.     ret
  86. getnumcdroms    endp
  87.  
  88. ;    /*\
  89. ;    |*|    int getfirstcdrom(void) 
  90. ;    |*|
  91. ;    |*|    Entry:    none
  92. ;    |*|
  93. ;    |*|    Exit:    return number of first cdrom drive 
  94. ;    |*|
  95. ;    \*/
  96.  
  97.     public getfirstcdrom
  98. getfirstcdrom    proc
  99.     push bp
  100.     mov bp, sp
  101.  
  102.     mov ax, 1500h
  103.     xor bx, bx
  104.     int 2Fh
  105.  
  106.     mov ax, cx
  107.  
  108.     pop bp
  109.     ret
  110. getfirstcdrom endp
  111.  
  112. ;    /*\
  113. ;    |*|    int getcdromlist(struct cdromdrivestruct far *cdromlist) 
  114. ;    |*|
  115. ;    |*|    fill buffer with drive identifiers and addresses 
  116. ;    |*|
  117. ;    |*|    Entry:    address of buffer
  118. ;    |*|
  119. ;    |*|    Exit:    0 if successful, -1 if error occurred
  120. ;    |*|
  121. ;    \*/
  122.  
  123.     public getcdromlist
  124. getcdromlist proc
  125.     push bp
  126.     mov bp, sp
  127.  
  128.     mov ax, 1501h
  129.     les bx, dParm1
  130.     int 2Fh
  131.  
  132.     pop bp
  133.     ret
  134. getcdromlist endp
  135.  
  136. ;    /*\
  137. ;    |*|    int getcopyrightfname(int drive, char far *copyrightfname) 
  138. ;    |*|
  139. ;    |*|    fill buffer with name of copyright file for drive 
  140. ;    |*|
  141. ;    |*|    Entry:    drive number, address of buffer
  142. ;    |*|
  143. ;    |*|    Exit:    0 if successful, -1 if error occurred
  144. ;    |*|
  145. ;    \*/
  146.  
  147.     public getcopyrightfname
  148. getcopyrightfname proc
  149.     push bp
  150.     mov bp, sp
  151.  
  152.     mov ax, 1502h
  153.     mov cx, wParm1
  154.     les bx, wParm2
  155.     int 2Fh
  156.     jnc okay
  157.  
  158.     mov lasterror, ax
  159.     mov ax, -1
  160.     jmp short done
  161.  
  162. okay:
  163.     xor ax, ax
  164.  
  165. done:
  166.     pop bp
  167.     ret
  168. getcopyrightfname endp
  169.  
  170. ;    /*\
  171. ;    |*|    int getabstractfname(int drive, char far *abstractfname)
  172. ;    |*|
  173. ;    |*|    fill buffer with name of abstract file for drive 
  174. ;    |*|
  175. ;    |*|    Entry:    drive number, address of buffer
  176. ;    |*|
  177. ;    |*|    Exit:    0 if successful, -1 if error occurred
  178. ;    |*|
  179. ;    \*/
  180.  
  181.     public getabstractfname
  182. getabstractfname proc
  183.     push bp
  184.     mov bp, sp
  185.  
  186.     mov ax, 1503h
  187.     mov cx, wParm1
  188.     les bx, wParm2
  189.     int 2Fh
  190.     jnc okay
  191.  
  192.     mov lasterror, ax
  193.     mov ax, -1
  194.     jmp short done
  195.  
  196. okay:
  197.     xor ax, ax
  198.  
  199. done:
  200.     pop bp
  201.     ret
  202. getabstractfname endp
  203.         
  204.  
  205. ;    /*\
  206. ;    |*|    int getbibliofname(int drive, char far *bibliofname)
  207. ;    |*|
  208. ;    |*|    fill buffer with name of bibliographic file for drive 
  209. ;    |*|
  210. ;    |*|    Entry:    drive number, address of buffer
  211. ;    |*|
  212. ;    |*|    Exit:    0 if successful, -1 if error occurred
  213. ;    |*|
  214. ;    \*/
  215.  
  216. getbibliofname proc
  217.     push bp
  218.     mov bp, sp
  219.  
  220.     mov ax, 1504h
  221.     mov cx, wParm1
  222.     les bx, wParm2
  223.     int 2Fh
  224.     jnc okay
  225.  
  226.     mov lasterror, ax
  227.     mov ax, -1
  228.     jmp short done
  229.  
  230. okay:
  231.     xor ax, ax
  232.  
  233. done:
  234.     pop bp
  235.     ret
  236. getbibliofname endp
  237.  
  238. ;    /*\
  239. ;    |*|    int readvtoc(int drive, int index, char far *dscbuf)
  240. ;    |*|
  241. ;    |*|    read entry from volume table of contents for drive 
  242. ;    |*|
  243. ;    |*|    Entry:    drive number, entry number, address of buffer
  244. ;    |*|
  245. ;    |*|    Exit:    return type of descriptor read, or -2 if error 
  246. ;    |*|
  247. ;    \*/
  248.  
  249.     public readvtoc
  250. readvtoc proc
  251.     push bp
  252.     mov bp, sp
  253.  
  254.     mov ax, 1505h
  255.     mov cx, wParm1
  256.     mov dx, wParm2
  257.     les bx, wParm3
  258.     int 2Fh
  259.     jnc okay
  260.  
  261.     mov lasterror, ax
  262.     mov ax, -2
  263.  
  264. okay:
  265.     cbw
  266.  
  267.     pop bp
  268.     ret
  269. readvtoc endp
  270.  
  271. ;    /*\
  272. ;    |*|    int absdiscread(int drive, int count, long sector, char far *buffer)
  273. ;    |*|
  274. ;    |*|    read one or more logical sectors for drive 
  275. ;    |*|    Entry:    drive number, count of sectors, 
  276. ;    |*|        starting sector number, address of buffer for data
  277. ;    |*|
  278. ;    |*|    Exit:    returns count of sectors read, -1 if error 
  279. ;    |*|
  280. ;    \*/
  281.  
  282.     public absdiscread
  283. absdiscread proc
  284.     push bp
  285.     mov bp, sp
  286.     push si
  287.     push di
  288.  
  289.     mov ax, 1508h
  290.     mov cx, wParm1
  291.     mov dx, wParm2
  292.     mov di, wParm3
  293.     mov si, wParm4
  294.     les bx, wParm5
  295.     int 2Fh
  296.     jnc okay
  297.  
  298.     mov lasterror, ax
  299.     mov ax, -1
  300.     jmp short done
  301.  
  302. okay:
  303.     mov ax, wParm2
  304.  
  305. done:
  306.     pop di
  307.     pop si
  308.     pop bp
  309.     ret
  310. absdiscread endp
  311.  
  312. ;    /*\
  313. ;    |*|    int absdiscwrite(int drive, int count, long sector, char far *buffer)
  314. ;    |*|
  315. ;    |*|    write one or more logical sectors for drive 
  316. ;    |*|
  317. ;    |*|    Entry:    drive number, count of sectors to write,
  318. ;    |*|        starting sector, address of buffer
  319. ;    |*|
  320. ;    |*|    Exit:    returns count of sectors written, -1 if error 
  321. ;    |*|
  322. ;    \*/
  323.  
  324.     public absdiscwrite
  325. absdiscwrite proc
  326.     push bp
  327.     mov bp, sp
  328.     push si
  329.     push di
  330.  
  331.     mov ax, 1509h
  332.     mov cx, wParm1
  333.     mov dx, wParm2
  334.     mov di, wParm3
  335.     mov si, wParm4
  336.     les bx, wParm5
  337.     int 2Fh
  338.     jnc okay
  339.  
  340.     mov lasterror, ax
  341.     mov ax, -1
  342.     jmp short done
  343.  
  344. okay:
  345.     mov ax, wParm2
  346.  
  347. done:
  348.     pop di
  349.     pop si
  350.     pop bp
  351.     ret
  352. absdiscwrite endp
  353.  
  354. ;    /*\
  355. ;    |*|    int chkdrive(int drive)
  356. ;    |*|
  357. ;    |*|    check if drive supported by mscdex 
  358. ;    |*|
  359. ;    |*|    Entry:    drive number
  360. ;    |*|
  361. ;    |*|    Exit:    return 0 if mscdex installed and drive is supported
  362. ;    |*|        return 1 if mscdex installed and drive not supported
  363. ;    |*|        return -1 if mscdex not installed 
  364. ;    |*|
  365. ;    \*/
  366.  
  367.     public chkdrive
  368. chkdrive proc
  369.     push bp
  370.     mov bp, sp
  371.  
  372.     mov ax, 150Bh
  373.     mov bx, 0
  374.     mov cx, wParm1
  375.     int 2Fh
  376.  
  377.     cmp bx, 0ADADh
  378.     jnz nomscdex
  379.  
  380.     cmp ax, 0
  381.     jz notcdrom
  382.  
  383.     mov ax, 0
  384.     jmp short done
  385.  
  386. nomscdex:
  387.     mov ax, -1
  388.     jmp short done
  389.  
  390. notcdrom:
  391.     mov ax, 1
  392.  
  393. done:
  394.     pop bp
  395.     ret
  396. chkdrive endp
  397.  
  398. ;    /*\
  399. ;    |*|    int getmscdexversion(void) 
  400. ;    |*|
  401. ;    |*|    Entry:    none
  402. ;    |*|
  403. ;    |*|    Exit:    return version of mscdex 
  404. ;    |*|
  405. ;    \*/
  406.  
  407.     public getmscdexversion
  408. getmscdexversion proc
  409.     push bp
  410.     mov bp, sp
  411.  
  412.     mov ax, 150Ch
  413.     xor bx, bx
  414.     int 2Fh
  415.  
  416.     mov ax, bx
  417.  
  418.     pop bp
  419.     ret
  420. getmscdexversion endp
  421.  
  422. ;    /*\
  423. ;    |*|    int getcdromunits(char far *cdromunits)
  424. ;    |*|
  425. ;    |*|    fill buffer with list of cdrom drives 
  426. ;    |*|
  427. ;    |*|    Entry:    address of buffer
  428. ;    |*|
  429. ;    |*|    Exit:    none
  430. ;    |*|
  431. ;    \*/
  432.  
  433.     public getcdromunits
  434. getcdromunits proc
  435.     push bp
  436.     mov bp, sp
  437.  
  438.     mov ax, 150Dh
  439.     les bx, dParm1
  440.     int 2Fh
  441.  
  442.     pop bp
  443.     ret
  444. getcdromunits endp
  445.  
  446. ;    /*\
  447. ;    |*|    int getvdescpref(int drive)
  448. ;    |*|
  449. ;    |*|    get preference for primary or supplementary descriptors 
  450. ;    |*|
  451. ;    |*|    Entry:    drive number
  452. ;    |*|
  453. ;    |*|    Exit:    return 0 or 1 (preference), or -1 if error 
  454. ;    |*|
  455. ;    \*/
  456.  
  457.     public getvdescpref
  458. getvdescpref proc
  459.     push bp
  460.     mov bp, sp
  461.  
  462.     mov ax, 150Eh
  463.     xor bx, bx
  464.     mov cx, wParm1
  465.     int 2Fh
  466.     jnc okay
  467.  
  468.     mov lasterror, ax
  469.     mov ax, -1
  470.  
  471. okay:
  472.     pop bp
  473.     ret
  474. getvdescpref endp
  475.  
  476. ;    /*\
  477. ;    |*|    int setvdescpref(int drive, int pref)
  478. ;    |*|
  479. ;    |*|    set preference for primary or supplementary descriptors 
  480. ;    |*|
  481. ;    |*|    Entry:    drive number, preference (0 primary, 1 secondary)
  482. ;    |*|
  483. ;    |*|    Exit:    return 0 if successful, -1 if error occurred
  484. ;    |*|
  485. ;    \*/
  486.  
  487.     public setvdescpref
  488. setvdescpref proc
  489.     push bp
  490.     mov bp, sp
  491.  
  492.     mov ax, 150Eh
  493.     mov bx, 1
  494.     mov cx, wParm1
  495.     mov dx, wParm2
  496.  
  497.     cmp dh, 1
  498.     jnz isvalid
  499.     cmp dl, 0
  500.     jnz invalid
  501.  
  502. isvalid:
  503.     int 2Fh
  504.     jnc okay
  505.  
  506.     mov lasterror, ax
  507.  
  508. invalid:
  509.     mov ax, -1
  510.     jmp short done
  511.  
  512. okay:
  513.     xor ax, ax
  514.  
  515. done:
  516.     pop bp
  517.     ret
  518. setvdescpref endp
  519.  
  520. ;    /*\
  521. ;    |*|    int getdirentry(int drive, char far *name, char far *buffer)
  522. ;    |*|
  523. ;    |*|    search directory for entry, fill buffer if found 
  524. ;    |*|
  525. ;    |*|    Entry:    drive number, address of file name, address of buffer
  526. ;    |*|
  527. ;    |*|    Exit:    return format of volume, -1 if error 
  528. ;    |*|
  529. ;    \*/
  530.  
  531.     public getdirentry
  532. getdirentry proc
  533.     push bp
  534.     mov bp, sp
  535.     push si
  536.     push di
  537.  
  538.     mov ax, 150Fh
  539.     mov cx, wParm1
  540.     les bx, wParm2
  541.     mov di, wParm4
  542.     mov si, wParm5
  543.     int 2Fh
  544.     jnc okay
  545.  
  546.     mov lasterror, ax
  547.     mov ax, -1
  548.  
  549. okay:
  550.     pop di
  551.     pop si
  552.     pop bp
  553.     ret
  554. getdirentry endp
  555.  
  556. ;    /*\
  557. ;    |*|    int senddevreq(int drive, void far *cdh) 
  558. ;    |*|
  559. ;    |*|    send device request 
  560. ;    |*|
  561. ;    |*|    Entry:    drive number, address of buffer
  562. ;    |*|
  563. ;    |*|    Exit:    none (status placed in buffer by driver)
  564. ;    |*|
  565. ;    \*/
  566.  
  567.     public senddevreq
  568. senddevreq proc
  569.     push bp
  570.     mov bp, sp
  571.  
  572.     mov ax, 1510h
  573.     mov cx, wParm1
  574.     les bx, wParm2
  575.     int 2Fh
  576.  
  577.     pop bp
  578.     ret
  579. senddevreq endp
  580.  
  581. ;    /*\
  582. ;    |*|    int getlasterror(void) 
  583. ;    |*|
  584. ;    |*|    return value in lasterror
  585. ;    |*|
  586. ;    |*|    Entry:    none
  587. ;    |*|
  588. ;    |*|    Exit:    last error value saved 
  589. ;    |*|
  590. ;    \*/
  591.  
  592.     public getlasterror
  593. getlasterror proc
  594.     push bp
  595.     mov bp, sp
  596.  
  597.     mov ax, lasterror
  598.  
  599.     pop bp
  600.     ret
  601. getlasterror endp
  602.  
  603. ;    /*\
  604. ;    |*|    int clearlasterror(void) 
  605. ;    |*|
  606. ;    |*|    Entry:    none
  607. ;    |*|
  608. ;    |*|    Exit:    last saved error value
  609. ;    |*|
  610. ;    \*/
  611.  
  612.     public clearlasterror
  613. clearlasterror proc
  614.     push bp
  615.     mov bp, sp
  616.  
  617.     xor ax, ax
  618.     xchg lasterror, ax
  619.  
  620.     pop bp
  621.     ret
  622. clearlasterror endp
  623. end
  624.