home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / ms_dos / cd_lib / src / cdr_mtp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-08  |  1.6 KB  |  70 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4. #include "define.h"
  5. /* #include <cdrfrb.h> */
  6.  
  7. #ifdef DEBUG
  8. main(int argc, char *argv[])
  9. {
  10.     struct TIMEADRS time, end_time;
  11.     
  12.     if (argc > 1) {
  13.         printf("input is %s\n", argv[1]);
  14.         time.min = (u_char) atoi(argv[1]);
  15.         time.sec = 0;
  16.         time.frame = 0;
  17.         end_time.min = time.min;
  18.         end_time.sec = time.sec + 10;
  19.         end_time.frame = time.frame;
  20.         printf("play %d分\n", time.min);
  21.         printf("return is %x\n", cdr_mtplay(0, &time, &end_time));
  22.     }
  23. }
  24. #endif
  25.  
  26. /* 音楽演奏スタート(時間指定) */
  27. /*
  28.  * decice_no:   device number (Towns CD-ROM -> 0)
  29.  * start_time: 演奏開始時間
  30.  * end_time: 演奏終了時間
  31.  * return: 0 -> 正常終了, 0以外 -> エラー
  32.  */
  33. int cdr_mtplay(int device_no, struct TIMEADRS *start_time, struct TIMEADRS *end_time)
  34. {
  35.     union REGS reg;
  36.     struct SREGS seg;
  37.     char buf[6];
  38.     
  39.     if (start_time == NULL || end_time == NULL) {
  40.         return -1;
  41.     }
  42.  
  43.     reg.h.ah = 0x50;
  44.     reg.h.al = (0xC0 | (u_char) device_no);
  45.     reg.x.cx = 0x0001;
  46.  
  47.     buf[0] = start_time->min;    /* 分 */
  48.     buf[1] = start_time->sec;    /* 秒 */
  49.     buf[2] = start_time->frame;    /* フレーム */
  50.     buf[3] = end_time->min;    /* 分 */
  51.     buf[4] = end_time->sec;    /* 秒 */
  52.     buf[5] = end_time->frame;    /* フレーム */
  53.  
  54.     reg.x.di = (u_int) buf;
  55.     segread(&seg);
  56.     seg.ds = seg.ss;
  57.  
  58.     int86x(0x93, ®, ®, &seg);
  59.     
  60.     if (reg.h.ah == 0) {
  61.         return 0;
  62.     } else if (reg.h.ah == 0x02) {   /* device number error */
  63.         return DEVERR;
  64.     } else if (reg.h.ah == 0x10) {   /* cd-da plaing */
  65.         return DEVPLY;          
  66.     } else {                         /* (reg.h.ah == 0x80) hard ware error */
  67.         return reg.x.cx;
  68.     }
  69. }
  70.