*** wcd.c.orig	Fri Jan 24 20:31:02 1997
--- wcd.c	Fri Jan 24 20:31:09 1997
***************
*** 14,19 ****
--- 14,24 ----
   *
   * Version 1.8, Thu Sep 28 21:04:16 MSK 1995
   */
+ /* modified by shige for CD-60D, Tue Jan 14 14:05:51 JST 1997
+  * modified by shige for CD-60D, Tue Jan 24 20:25:56 JST 1997
+  */
+ /* #undef CD60DTEST */
+ #define CD60DTEST
  
  #include "wdc.h"
  #include "wcd.h"
***************
*** 620,628 ****
--- 625,639 ----
  
  	if (! (t->flags & F_NOPLAYCD)) {
  		t->cf.kdc_state = DC_BUSY;
+ #ifndef CD60DTEST
  		result = atapi_request_wait (t->ata, t->unit, ATAPI_PLAY_CD,
  			cmd == ATAPI_PLAY_MSF ? 2 : 0, a2, a3, a4, a5, a6,
  			a7, a8, a9, 0, 0, 0, 0, 0, 0, addr, count);
+ #else /* CD60DTEST */
+ 		result = atapi_request_wait (t->ata, t->unit, cmd,
+ 			a1, a2, a3, a4, a5, a6,
+ 			a7, a8, a9, 0, 0, 0, 0, 0, 0, addr, count);
+ #endif /* CD60DTEST */
  		t->cf.kdc_state = DC_IDLE;
  		if (result.code == RES_ERR &&
  		    (result.error & AER_SKEY) == AER_SK_ILLEGAL_REQUEST) {
***************
*** 650,655 ****
--- 661,670 ----
  	*f = lba % 75;
  }
  
+ #ifdef CD60DTEST
+ # define HEX2BCD(c) (((c)<=99)?(u_char)(((c)/10)<<4|(c)%10):0)
+ #endif /* CD60DTEST */
+ 
  /*
   * Perform special action on behalf of the user.
   * Knows about the internals of this device
***************
*** 739,747 ****
  
  		if (! t->toc.hdr.ending_track)
  			return (EIO);
! 		if (te->starting_track < toc->hdr.starting_track ||
! 		    te->starting_track > toc->hdr.ending_track)
  			return (EINVAL);
  
  		len = (toc->hdr.ending_track - te->starting_track + 2) *
  			sizeof(toc->tab[0]);
--- 754,765 ----
  
  		if (! t->toc.hdr.ending_track)
  			return (EIO);
! 		if ((te->starting_track < toc->hdr.starting_track ||
! 		    te->starting_track > toc->hdr.ending_track) &&
! 		    te->starting_track != 0xaa)
  			return (EINVAL);
+ 		if (te->starting_track == 0xaa)
+ 			te->starting_track = toc->hdr.ending_track + 1;
  
  		len = (toc->hdr.ending_track - te->starting_track + 2) *
  			sizeof(toc->tab[0]);
***************
*** 756,764 ****
  
  			buf = t->toc;
  			toc = &buf;
! 			e = toc->tab + toc->hdr.ending_track -
! 				te->starting_track + 2;
! 			while (--e >= toc->tab)
  				lba2msf (e->addr.lba, &e->addr.msf.minute,
  				    &e->addr.msf.second, &e->addr.msf.frame);
  		}
--- 774,781 ----
  
  			buf = t->toc;
  			toc = &buf;
! 			e = toc->tab + toc->hdr.ending_track + 1;
! 			while (--e >= toc->tab + te->starting_track - 1)
  				lba2msf (e->addr.lba, &e->addr.msf.minute,
  				    &e->addr.msf.second, &e->addr.msf.frame);
  		}
***************
*** 812,829 ****
--- 829,868 ----
  	case CDIOCPLAYMSF: {
  		struct ioc_play_msf *args = (struct ioc_play_msf*) addr;
  
+ #ifndef CD60DTEST
  		return wcd_play (t, ATAPI_PLAY_MSF, 0, 0,
  			args->start_m, args->start_s, args->start_f,
  			args->end_m, args->end_s, args->end_f, 0, 0, 0);
+ #else /* CD60DTEST */
+ 		return wcd_play (t, ATAPI_PLAY_MSF, 0, 0,
+ 			HEX2BCD(args->start_m), HEX2BCD(args->start_s), 
+ 			HEX2BCD(args->start_f),
+ 			HEX2BCD(args->end_m), HEX2BCD(args->end_s),
+ 			HEX2BCD(args->end_f), 0, 0, 0);
+ #endif /* CD60DTEST */
  	}
  	case CDIOCPLAYBLOCKS: {
  		struct ioc_play_blocks *args = (struct ioc_play_blocks*) addr;
  
+ #ifndef CD60DTEST
  		return wcd_play (t, ATAPI_PLAY_BIG, 0,
  			args->blk >> 24 & 0xff, args->blk >> 16 & 0xff,
  			args->blk >> 8 & 0xff, args->blk & 0xff,
  			args->len >> 24 & 0xff, args->len >> 16 & 0xff,
  			args->len >> 8 & 0xff, args->len & 0xff, 0, 0);
+ #else /* CD60DTEST */
+ 		{
+ 			u_long start,end;
+ 			u_char s_m,s_s,s_f,e_m,e_s,e_f;
+ 
+ 			start=args->blk; end=args->blk+args->len;
+ 			lba2msf(start,&s_m,&s_s,&s_f);
+ 			lba2msf(end,&e_m,&e_s,&e_f);
+ 			return wcd_play (t, ATAPI_PLAY_MSF, 0, 0,
+ 				HEX2BCD(s_m),HEX2BCD(s_s),HEX2BCD(s_f),
+ 				HEX2BCD(e_m),HEX2BCD(e_s),HEX2BCD(e_f),0,0,0);
+ 		}
+ #endif /* CD60DTEST */
  	}
  	case CDIOCPLAYTRACKS: {
  		struct ioc_play_track *args = (struct ioc_play_track*) addr;
***************
*** 846,856 ****
--- 885,909 ----
  		start = t->toc.tab[t1].addr.lba;
  		len = t->toc.tab[t2].addr.lba - start;
  
+ #ifndef CD60DTEST
  		return wcd_play (t, ATAPI_PLAY_BIG, 0,
  			start >> 24 & 0xff, start >> 16 & 0xff,
  			start >> 8 & 0xff, start & 0xff,
  			len >> 24 & 0xff, len >> 16 & 0xff,
  			len >> 8 & 0xff, len & 0xff, 0, 0);
+ #else /* CD60DTEST */
+ 		{
+ 		    	u_long end;
+ 			u_char s_m,s_s,s_f,e_m,e_s,e_f;
+ 
+ 			end=start+len;
+ 			lba2msf(start,&s_m,&s_s,&s_f);
+ 			lba2msf(end,&e_m,&e_s,&e_f);
+ 			return wcd_play (t, ATAPI_PLAY_MSF, 0, 0,
+ 				HEX2BCD(s_m),HEX2BCD(s_s),HEX2BCD(s_f),
+ 				HEX2BCD(e_m),HEX2BCD(e_s),HEX2BCD(e_f),0,0,0);
+ 		}
+ #endif /* CD60DTEST */
  	}
  	case CDIOCGETVOL: {
  		struct ioc_vol *arg = (struct ioc_vol*) addr;
