home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FreeWare Collection 3
/
FreeSoftwareCollection3pd199x-jp.img
/
pao
/
ms_dos
/
cdplay
/
src
/
cdr.c
< prev
next >
Wrap
Text File
|
1980-01-02
|
8KB
|
276 lines
/******************************************************************************
**
** CDR.LIB << MSC V5.1 >>
**
** ※コンパイル時に /Zp オプションを必ずつけること!
**
** ただ単純にMS-DOSでCDを聴きたいためだけに作ったので
** 最低限必要な機能しかありません。しかも、C言語で作成してあるのです。
** きまぐれで作ったので・・・・そのうちアセンブラで作りたいなぁ・・・・!
**
** <HISTORY>
** 1990.02.21 : CREATE
** 1990.05.12 : リピート回数のバグ修正。
** 1990.06.29 : CDR_continue()の追加。
**
** Programed by Y.HIRATA Nifty-ID (NAB03321)
**
******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <conio.h>
#include "cdr.h"
#define CDR_INT 0x93
union REGS regs, regs ;
struct SREGS sregs ;
typedef struct _TRACK_INF {
unsigned char min ;
unsigned char sec ;
unsigned char frame ;
} TRACK_INF ;
typedef struct _TOC {
unsigned char cdtype;
unsigned char sttrack;
unsigned char endtrack;
TRACK_INF disc ;
TRACK_INF track[99] ;
} TOC ;
/******************************************************************************
CDR_cdinfo
******************************************************************************/
int CDR_cdinfo( deviceno, cdtype, starttrack, endtrack, tracktime, disktime )
int deviceno ; /* デバイス番号 */
int *cdtype ; /* コンパクトディスクタイプ */
int *starttrack ; /* 先頭トラック(曲)番号 */
int *endtrack ; /* 最終トラック(曲)番号 */
char *tracktime ; /* トラック内演奏時間 */
char *disktime ; /* ディスク内演奏時間 */
{
TOC toc ;
int ret ;
regs.h.ah = 0x54 ;
deviceno |= 0xc0 ;
regs.h.al = deviceno ;
regs.x.cx = 0;
regs.x.di = (unsigned int)&toc ;
segread( &sregs ) ;
int86x( CDR_INT,®s,®s,&sregs ) ;
ret = 0 ; /* 正常終了 */
if ( regs.h.ah == 0x02 ) /* デバイス番号誤り */
ret = DEVERR ;
else if ( regs.h.ah == 0x10 ) /* 音楽演奏中 */
ret = DEVPLY ;
else if ( regs.h.ah == 0x80 ) /* ハードエラー */
ret = regs.x.cx ;
*cdtype = toc.cdtype ;
*starttrack = toc.sttrack ;
*endtrack = toc.endtrack ;
memcpy( tracktime,(char *)toc.track,99*3 ) ;
memcpy( disktime,(char *)&toc.disc,3 ) ;
return ( ret ) ;
}
/******************************************************************************
CDR_mtplay
******************************************************************************/
int CDR_mtplay( deviceno, starttime, endtime )
int deviceno ; /* デバイス番号 */
char *starttime ; /* 演奏開始時間 */
char *endtime ; /* 演奏終了時間 */
{
TRACK_INF track_inf[2] ;
int ret ;
memcpy( &track_inf[0],starttime,3 ) ;
memcpy( &track_inf[1],endtime,3 ) ;
regs.h.ah = 0x50 ;
deviceno |= 0xc0 ;
regs.h.al = deviceno ;
regs.h.ch = 0;
regs.h.cl = 0x01;
regs.x.di = (unsigned int)track_inf ;
segread( &sregs ) ;
int86x( CDR_INT,®s,®s,&sregs ) ;
ret = 0 ; /* 正常終了 */
if ( regs.h.ah == 0x02 ) /* デバイス番号誤り */
ret = DEVERR ;
else if ( regs.h.ah == 0x10 ) /* 音楽演奏中 */
ret = DEVPLY ;
else if ( regs.h.ah == 0x80 ) /* ハードエラー */
ret = regs.x.cx ;
return ( ret ) ;
}
/******************************************************************************
CDR_mtrplay
******************************************************************************/
int CDR_mtrplay( deviceno, starttime, endtime, count )
int deviceno ; /* デバイス番号 */
char *starttime ; /* 演奏開始時間 */
char *endtime ; /* 演奏終了時間 */
unsigned char count ; /* リピート回数 */
{
TRACK_INF track_inf[2] ;
int ret ;
memcpy( &track_inf[0],starttime,3 ) ;
memcpy( &track_inf[1],endtime,3 ) ;
regs.h.ah = 0x50 ;
deviceno |= 0xc0 ;
regs.h.al = deviceno ;
regs.h.bh = count - 1 ;
/* ↑マニュアルではリピート回数って書いてあるのに、TBIOSを除いて見たら-1していた。 */
regs.h.ch = 0xfe;
regs.h.cl = 0x01;
regs.x.di = (unsigned int)track_inf ;
segread( &sregs ) ;
int86x( CDR_INT,®s,®s,&sregs ) ;
ret = 0 ; /* 正常終了 */
if ( regs.h.ah == 0x02 ) /* デバイス番号誤り */
ret = DEVERR ;
else if ( regs.h.ah == 0x10 ) /* 音楽演奏中 */
ret = DEVPLY ;
else if ( regs.h.ah == 0x80 ) /* ハードエラー */
ret = regs.x.cx ;
return ( ret ) ;
}
/******************************************************************************
CDR_mphase
******************************************************************************/
int CDR_mphase( deviceno, status, nowmusicno, tracktime, disktime )
int deviceno ; /* デバイス番号 */
int *status ; /* 音楽の演奏状態 */
int *nowmusicno ; /* 現在演奏中の曲番号 */
char *tracktime ; /* トラック内演奏時間 */
char *disktime ; /* ディスク内演奏時間 */
{
struct _status_data {
unsigned char res1 ;
unsigned char now ;
unsigned char res2 ;
TRACK_INF tracktime ;
unsigned char res3 ;
TRACK_INF disktime ;
} status_data ;
int ret ;
regs.h.ah = 0x53 ;
deviceno |= 0xc0 ;
regs.h.al = deviceno ;
regs.x.cx = 0;
regs.x.di = (unsigned int)&status_data ;
segread( &sregs ) ;
int86x( CDR_INT,®s,®s,&sregs ) ;
ret = 0 ; /* 正常終了 */
if ( regs.h.ah == 0x02 ) /* デバイス番号誤り */
ret = DEVERR ;
else if ( regs.h.ah == 0x80 ) /* ハードエラー */
ret = regs.x.cx ;
*status = regs.h.al ;
*nowmusicno = status_data.now ;
memcpy( tracktime,&status_data.tracktime,3 ) ;
memcpy( disktime,&status_data.disktime,3 ) ;
return ( ret ) ;
}
/******************************************************************************
CDR_pause
******************************************************************************/
int CDR_pause( deviceno )
int deviceno ; /* デバイス番号 */
{
int ret ;
regs.h.ah = 0x55 ;
deviceno |= 0xc0 ;
regs.h.al = deviceno ;
regs.h.ch = 0;
segread( &sregs ) ;
int86x( CDR_INT,®s,®s,&sregs ) ;
ret = 0 ; /* 正常終了 */
if ( regs.h.ah == 0x02 ) /* デバイス番号誤り */
ret = DEVERR ;
else if ( regs.h.ah == 0x22 ) /* 音楽一時停止状態 */
ret = DEVPAUSE ;
else if ( regs.h.ah == 0x80 ) /* ハードエラー */
ret = regs.x.cx ;
return ( ret ) ;
}
/******************************************************************************
CDR_continue
******************************************************************************/
int CDR_continue( deviceno )
int deviceno ; /* デバイス番号 */
{
int ret ;
regs.h.ah = 0x56 ;
deviceno |= 0xc0 ;
regs.h.al = deviceno ;
regs.h.ch = 0;
segread( &sregs ) ;
int86x( CDR_INT,®s,®s,&sregs ) ;
ret = 0 ; /* 正常終了 */
if ( regs.h.ah == 0x02 ) /* デバイス番号誤り */
ret = DEVERR ;
else if ( regs.h.ah == 0x10 ) /* 音楽演奏中 */
ret = DEVPLY ;
else if ( regs.h.ah == 0x23 ) /* 音楽一時停止状態でない */
ret = DEVNPAUSE ;
else if ( regs.h.ah == 0x80 ) /* ハードエラー */
ret = regs.x.cx ;
return ( ret ) ;
}
/******************************************************************************
CDR_mstop
******************************************************************************/
int CDR_mstop( deviceno )
int deviceno ; /* デバイス番号 */
{
int ret ;
regs.h.ah = 0x52 ;
deviceno |= 0xc0 ;
regs.h.al = deviceno ;
regs.h.ch = 0;
segread( &sregs ) ;
int86x( CDR_INT,®s,®s,&sregs ) ;
ret = 0 ; /* 正常終了 */
if ( regs.h.ah == 0x02 ) /* デバイス番号誤り */
ret = DEVERR ;
else if ( regs.h.ah == 0x80 ) /* ハードエラー */
ret = regs.x.cx ;
return ( ret ) ;
}