home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <dos.h>
- #include "define.h"
- /* #include <cdrfrb.h> */
-
- #ifdef DEBUG
- main(int argc, char *argv[])
- {
- struct TIMEADRS time, end_time;
-
- if (argc > 1) {
- printf("input is %s\n", argv[1]);
- time.min = (u_char) atoi(argv[1]);
- time.sec = 0;
- time.frame = 0;
- end_time.min = time.min;
- end_time.sec = time.sec + 10;
- end_time.frame = time.frame;
- printf("play %d分\n", time.min);
- printf("return is %x\n", cdr_mtplay(0, &time, &end_time));
- }
- }
- #endif
-
- /* 音楽演奏スタート(時間指定) */
- /*
- * decice_no: device number (Towns CD-ROM -> 0)
- * start_time: 演奏開始時間
- * end_time: 演奏終了時間
- * return: 0 -> 正常終了, 0以外 -> エラー
- */
- int cdr_mtplay(int device_no, struct TIMEADRS *start_time, struct TIMEADRS *end_time)
- {
- union REGS reg;
- struct SREGS seg;
- char buf[6];
-
- if (start_time == NULL || end_time == NULL) {
- return -1;
- }
-
- reg.h.ah = 0x50;
- reg.h.al = (0xC0 | (u_char) device_no);
- reg.x.cx = 0x0001;
-
- buf[0] = start_time->min; /* 分 */
- buf[1] = start_time->sec; /* 秒 */
- buf[2] = start_time->frame; /* フレーム */
- buf[3] = end_time->min; /* 分 */
- buf[4] = end_time->sec; /* 秒 */
- buf[5] = end_time->frame; /* フレーム */
-
- reg.x.di = (u_int) buf;
- segread(&seg);
- seg.ds = seg.ss;
-
- int86x(0x93, ®, ®, &seg);
-
- if (reg.h.ah == 0) {
- return 0;
- } else if (reg.h.ah == 0x02) { /* device number error */
- return DEVERR;
- } else if (reg.h.ah == 0x10) { /* cd-da plaing */
- return DEVPLY;
- } else { /* (reg.h.ah == 0x80) hard ware error */
- return reg.x.cx;
- }
- }
-