diff -urN mcd-0.1/Makefile mcd-0.2/Makefile
--- mcd-0.1/Makefile	Sun Jul  8 15:19:11 2001
+++ mcd-0.2/Makefile	Thu Jul 12 00:49:51 2001
@@ -2,31 +2,34 @@
 #
 # Change it to your needs, see also params.h !
 
-CC	= gcc
-#CC	= diet gcc
-RM	= rm -f
-STRIP	= strip -R .note -R .comment
+MANDIR	= /usr/share/man
+BINDIR	= /usr/bin
 
-INCLUDE	=
+#CC	= gcc
+CC	= diet gcc
 CFLAGS	= -O2 -Wall -pipe -fomit-frame-pointer
 LDFLAGS	= 
 
+S_FLAGS	= -R .note -R .comment
+
 SRC	= $(shell ls *.c)
 OBJS	= $(SRC:.c=.o)
 PRGS	= mcd
 
-all: $(PRGS)
+all: clean $(PRGS)
 
 mcd: $(OBJS)
-	$(STRIP) -x $(OBJS)
+	strip $(S_FLAGS) -x $(OBJS)
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS)
-	$(STRIP) mcd
+	strip $(S_FLAGS) mcd
 
 clean:
-	$(RM) $(OBJS) mcd
+	rm -rf $(OBJS) mcd
 
 install:
-	@echo -e '\nDo it yourself !\n'
+	cp mcd $(BINDIR)
+	cp mcd.1 $(MANDIR)/man1
+	gzip $(MANDIR)/man1/mcd.1
 
 .c.o:
-	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
+	$(CC) $(CFLAGS) -c $< -o $@
diff -urN mcd-0.1/cddev.c mcd-0.2/cddev.c
--- mcd-0.1/cddev.c	Sun Jul  8 15:02:43 2001
+++ mcd-0.2/cddev.c	Thu Jul 12 02:19:06 2001
@@ -6,12 +6,56 @@
  */
 #include "mcd.h"
 
-int cd_init(const char *cdpath, struct mcd *cd) {
+static void cd_playmsf(struct mcd *cd, struct cdrom_msf *msf);
+
+static void cd_playmsf(struct mcd *cd, struct cdrom_msf *msf) {
+ if (cd->cds.cdsc_audiostatus == CDROM_AUDIO_PLAY) {
+ if (ioctl(cd->fd,CDROMPAUSE,NULL)<0)
+  draw_status("error, while stopping",1);
+ }
+ if (ioctl(cd->fd,CDROMPLAYMSF, msf)<0)
+  draw_status("error, while playing",1);
+ return;
+}
+
+/* GLOBAL */
+
+/* looks a bit strange, but is a really simple (inefficient) thought */
+/* generates new t[i].rnd */
+void cd_initshuffle(struct mcd *cd) {
+ register unsigned seed;
+ int i;
+
+ seed=(unsigned)time(NULL);
+ for (i=1;i<=cd->title[1];i++) { /* title[1]==last */
+  seed+=i;srand(seed); /* stupid seed :P */
+  cd->t[i].rnd=1+(int)((double)cd->title[1]*rand()/(RAND_MAX+1.));
+  /* is number already given ? */
+  for (cd->t[0].rnd=1;cd->t[0].rnd<i;cd->t[0].rnd++) { /* t[0].rnd is count */
+   /* if so, break out and do it again */
+   if (cd->t[i].rnd==cd->t[cd->t[0].rnd].rnd) --i;
+  }
+ }
+ return;
+}
+
+void cd_randomize(struct mcd *cd) {
+ register int i;
+ struct track h[MCD_CDAUDIO_MAX+1];
+ for (i=1;i<=cd->title[1];i++) h[i]=cd->t[i]; /* be sure */
+ if (cd->method==M_SHUFFLE) {
+  for (i=1;i<=cd->title[1];i++) {cd->t[h[i].rnd]=h[i];}
+ } else {
+  for (i=1;i<=cd->title[1];i++) {cd->t[h[i].nr]=h[i];}
+ }
+ return;
+}
 
+int cd_init(const char *cdpath, struct mcd *cd) {
  cd->fd=open(cdpath,O_RDONLY|O_NONBLOCK);
  if (cd->fd<0) return -1;
- if ((cd->cdstat[0]=ioctl(cd->fd,CDROM_DISC_STATUS,NULL)<0)) return -1;
- if (cd->cdstat[0]==(100||105)) return -2;
+ if ((cd->status=ioctl(cd->fd,CDROM_DISC_STATUS,NULL)<0)) return -1;
+ if (cd->status==(100||105)) return -2;
  return 0;
 }
 
@@ -22,17 +66,18 @@
  struct cdrom_tochdr cdth;        /* TocHdr Stuff */
 
  if (ioctl(cd->fd, CDROMREADTOCHDR, &cdth)<0) {
-  draw_status("can't read disc       ",0);
+  draw_status("can't read disc",1);
   return -1;
  }
  /* track[1] - [last-1])*/
- for(i=1;i<=cdth.cdth_trk1 && i<=MCD_CDAUDIO_MAX;i++) {
+ for (i=1;i<=cdth.cdth_trk1 && i<=MCD_CDAUDIO_MAX;i++) {
   cd->cdte[i].cdte_track=i;
   cd->cdte[i].cdte_format=CDROM_MSF;
   if (ioctl(cd->fd, CDROMREADTOCENTRY, &cd->cdte[i])<0) {
-   draw_status("can't read disc       ",0);
+   draw_status("can't read disc",1);
    return -1;
   } else {
+   cd->t[i].nr=i;
    cd->t[i].audio=cd->cdte[i].cdte_ctrl & CDROM_DATA_TRACK;
    tmp[i].min=cd->cdte[i].cdte_addr.msf.minute;
    tmp[i].sec=cd->cdte[i].cdte_addr.msf.second;
@@ -49,9 +94,10 @@
  cd->cdte[0].cdte_track=CDROM_LEADOUT;
  cd->cdte[0].cdte_format=CDROM_MSF;
  if (ioctl(cd->fd, CDROMREADTOCENTRY, &cd->cdte[0])<0) {
-  draw_status("can't read disc       ",0);
+  draw_status("can't read disc",1);
   return -1;
  } else {
+  cd->t[i].nr=i;
   cd->t[0].audio=cd->cdte[0].cdte_ctrl & CDROM_DATA_TRACK;
   cd->t[0].min=cd->cdte[0].cdte_addr.msf.minute;
   cd->t[0].sec=cd->cdte[0].cdte_addr.msf.second;
@@ -63,12 +109,10 @@
    cd->t[i-1].min--;cd->t[i-1].sec+=60;
   }
  }
- cd->title[1]=cdth.cdth_trk1; /* last playable title */
  updates[U_TRACKS]=1;
- return cdth.cdth_trk1;
+ return cd->title[1]=cdth.cdth_trk1; /* init all these stuff */
 }
 
-/* normal/update/dirty, last value counts */
 int cd_readsubchannel(struct mcd *cd) {
  struct cdrom_volctrl cdv; /* Volume Stuff */
 
@@ -77,8 +121,18 @@
  if (ioctl(cd->fd,CDROMSUBCHNL,&cd->cds)<0) return -1;
 
  /* audiostatus changed */
- if (cd->cds.cdsc_audiostatus!=cd->cdstat[0]) {
-  cd->cdstat[0]=cd->cds.cdsc_audiostatus;
+ if (cd->cds.cdsc_audiostatus!=cd->status) {
+  cd->status=cd->cds.cdsc_audiostatus;
+  if (cd->method==M_INTRO) {
+   updates[U_TRACKS]=1;
+   cd->title[0]++;
+   cd_start(&cd[0]);
+  }
+  if ((cd->method==M_REPEAT_CD) && cd->title[0]==cd->title[1]) {
+   updates[U_TRACKS]=1;
+   cd->title[0]=1;
+   cd_start(&cd[0]);
+  }
   updates[U_STATUS]=1;
  }
 
@@ -95,98 +149,99 @@
 
  /* track changed */
  if (cd->cds.cdsc_trk!=cd->title[0]) { /* title[0]=current title[1]=max */
-  if (cd->method[0]==M_REPEAT_TRK) {
+  if (cd->method==M_REPEAT_TRK) {
    cd_start(&cd[0]);
    return cd->title[0];
   }
   cd->title[0]=cd->cds.cdsc_trk;
   updates[U_TRACKS]=1;
  }
+
  return cd->cds.cdsc_trk; /* current title may be usefull :) */
 }
 
-
-/* title[0]=current / title[1]=last */
+/* set title[0] to new track before */
 void cd_start(struct mcd *cd) {
- register int tmp=0;
  struct cdrom_msf msf;
 
- if (cd->title[0]>cd->title[1]) {
-  draw_status("what do you want ?    ",1);return;
- } else {
-  tmp=(cd->title[0]<=cd->title[1])?cd->title[0]:0; /* track or leadout? */
- }
+ /* checking for last/first */
+ if (cd->title[0]>cd->title[1]) cd->title[0]=1;
+ if (cd->title[0]<1) cd->title[0]=cd->title[1];
 
  msf.cdmsf_min0   = cd->cdte[cd->title[0]].cdte_addr.msf.minute;
  msf.cdmsf_sec0   = cd->cdte[cd->title[0]].cdte_addr.msf.second;
  msf.cdmsf_frame0 = cd->cdte[cd->title[0]].cdte_addr.msf.frame;
- msf.cdmsf_sec1   = cd->cdte[0].cdte_addr.msf.second;
- msf.cdmsf_min1   = cd->cdte[0].cdte_addr.msf.minute;
- msf.cdmsf_frame1 = cd->cdte[0].cdte_addr.msf.frame;
-
-/* for DEBUGGING the methods :) 
- gotoxy(80,30);
- _printf("\ntmp=%02d t[0]=%02d t[1]=%02d %02d:%02d->%02d:%02d",
- tmp,cd->title[0],cd->title[1],
- msf.cdmsf_min0, msf.cdmsf_sec0,
- msf.cdmsf_min1, msf.cdmsf_sec1);
-*/
- if (cd->cds.cdsc_audiostatus == CDROM_AUDIO_PLAY) {
-  if (ioctl(cd->fd,CDROMPAUSE,NULL)<0)
-   draw_status("error, while stopping ",1);
+ if (cd->method==M_INTRO) {
+  msf.cdmsf_min1   = cd->cdte[cd->title[0]].cdte_addr.msf.minute;
+  msf.cdmsf_sec1   = cd->cdte[cd->title[0]].cdte_addr.msf.second+MCD_INTRO_TIME;
+  msf.cdmsf_frame1 = cd->cdte[cd->title[0]].cdte_addr.msf.frame;
+ } else {
+  /* leadout */
+  msf.cdmsf_sec1   = cd->cdte[0].cdte_addr.msf.second;
+  msf.cdmsf_min1   = cd->cdte[0].cdte_addr.msf.minute;
+  msf.cdmsf_frame1 = cd->cdte[0].cdte_addr.msf.frame;
  }
- if (ioctl(cd->fd,CDROMPLAYMSF, &msf)<0)
-  draw_status("error, while playing  ",1);
-}
 
+ cd_playmsf(&cd[0], &msf);
+ return;
+}
 
 /* only for skipping, rest is done via cd_play(..)! */
 void cd_skip(struct mcd *cd, int secs) {
  struct cdrom_msf msf;
 
- if (cd->method[0]==M_INTRO) return;
+ if (cd->method==M_INTRO) return; /* skipping, if intros */
+
+ if ((cd->title[0]==1) && (secs<0)) {
+  if (cd->cds.cdsc_absaddr.msf.minute*60+cd->cds.cdsc_absaddr.msf.second+secs<=2)
+  return; /* we ignore such things -- start */
+ }
+
  secs += cd->cds.cdsc_absaddr.msf.minute * 60 + cd->cds.cdsc_absaddr.msf.second;
  msf.cdmsf_min0   = secs / 60;
  msf.cdmsf_sec0   = secs % 60;
  msf.cdmsf_frame0 = 0;
- msf.cdmsf_min1   = cd->cdte[cd->title[1]].cdte_addr.msf.minute;
- msf.cdmsf_sec1   = cd->cdte[cd->title[1]].cdte_addr.msf.second;
- msf.cdmsf_frame1 = cd->cdte[cd->title[1]].cdte_addr.msf.frame;
+ msf.cdmsf_min1   = cd->cdte[0].cdte_addr.msf.minute;
+ msf.cdmsf_sec1   = cd->cdte[0].cdte_addr.msf.second;
+ msf.cdmsf_frame1 = cd->cdte[0].cdte_addr.msf.frame;
 
- if (cd->cds.cdsc_audiostatus == CDROM_AUDIO_PLAY) {
- if (ioctl(cd->fd,CDROMPAUSE,NULL)<0)
-   draw_status("error, while stopping ",1);
- }
- if (ioctl(cd->fd,CDROMPLAYMSF, &msf)<0)
-   draw_status("error, while playing  ",1);
+ if (msf.cdmsf_min0*60*75+msf.cdmsf_sec0*75+msf.cdmsf_frame0
+  >  msf.cdmsf_min1*60*75+msf.cdmsf_sec1*75+msf.cdmsf_frame1)
+  return; /* we ignore also this -- end */
+
+ cd_playmsf(&cd[0], &msf);
+ return;
 }
 
 void cd_stop(struct mcd *cd) {
- if (cd->cdstat[0]==CDROM_AUDIO_PLAY)
- ioctl(cd->fd,CDROMSTOP,NULL);
+ if (cd->cds.cdsc_audiostatus == CDROM_AUDIO_PLAY)
+ if (ioctl(cd->fd,CDROMSTOP,NULL)<0)
+  draw_status("error, while stopping",1);
+ return;
 }
 
 void cd_pauseresume(struct mcd *cd) {
- switch (cd->cdstat[0]) {
+ switch (cd->cds.cdsc_audiostatus) {
  case CDROM_AUDIO_PLAY:
   ioctl(cd->fd,CDROMPAUSE,NULL);
  break;
  case CDROM_AUDIO_PAUSED:
   ioctl(cd->fd,CDROMRESUME,NULL);
  break;
+ default: draw_status("request ignored",1);
  }
+ return;
 }
 
 void cd_eject(int *fd) {
- draw_status("opening cdrom         ",0);
+ draw_status("opening cdrom",1);
  ioctl(*fd,CDROMSTOP,NULL);
  ioctl(*fd,CDROMEJECT,NULL);
- havecd=0;
+ return;
 }
 
 void cd_close(int *fd) {
- draw_status("reading cdrom         ",0);
+ draw_status("reading cdrom",1);
  ioctl(*fd,CDROMCLOSETRAY,NULL);
- havecd=1;
+ return;
 }
-
diff -urN mcd-0.1/doc/COPYING mcd-0.2/doc/COPYING
--- mcd-0.1/doc/COPYING	Thu Jan  1 01:00:00 1970
+++ mcd-0.2/doc/COPYING	Sat Jun 16 04:05:11 2001
@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff -urN mcd-0.1/doc/README mcd-0.2/doc/README
--- mcd-0.1/doc/README	Thu Jan  1 01:00:00 1970
+++ mcd-0.2/doc/README	Thu Jul 12 23:50:54 2001
@@ -0,0 +1,71 @@
+
+ WHAT IS IT
+===========
+
+- mcd (0.2) is a small (maybe the smallest) cd-player for _linux_
+- it should compile/run out off the box
+- it compiles against dietlibc (12kb static!)
+- working play methods: reapeat cd, repeat track and intro (@ some time shuffle)
+
+
+ REQUIREMENTS
+==============
+
+- linux >=2.2
+- /usr/include/termios.h (tcgetattr(),...)
+
+
+
+ COPYING
+=========
+
+Copyright (C) 2000 Tino Reichardt <der@mcmilk.de>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+AND
+
+Author strongly advices against using this code, or a part of it,
+in an application designed to run on any Microsoft(tm) platfrom.
+
+
+
+ TODO
+======
+
+- term resizing stuff works correct, if not started from mc, because mc seems
+  to catch the SIGWINCH signal !!!
+  (btw: a new rewrite of the midnight commander will be my next project ...)
+- maybe some things of the wishlist... if someone ask me, i will do it, but for
+  now, this (mcd-0.2) is the stable release of mcd !
+- shuffle isn't really inclued yet !!!!!
+
+
+ WISHLIST
+==========
+
+- CD-Text (i like this!)
+- maybe cddb (i don't like it much!)
+
+
+ HOMEPAGE
+==========
+
+ http://www.mcmilk.de/projects/mcd/
+
+
+
+ BUGS
+======
+
+Please report bugs to:
+
+  Tino Reichardt <milky-mcd@mcmilk.de>
diff -urN mcd-0.1/doc/README.de mcd-0.2/doc/README.de
--- mcd-0.1/doc/README.de	Thu Jan  1 01:00:00 1970
+++ mcd-0.2/doc/README.de	Sun Jul  8 15:07:37 2001
@@ -0,0 +1,102 @@
+siehe README !!!
+
+
+
+Technisches:
+
+
+CD-DA Standard alias RedBook
+============================
+
+Der Standard der Audio-CD (CD-DA) wurde also 1982 von Philips und Sony im
+RedBook definiert. Die maximale Spielzeit einer 12cm-CD beträgt 74 Minuten und
+33 Sekunden, eine 8cm Single-CD hat eine Laufzeit von etwa 21 Minuten. Auf
+einer CD können bis zu 99 Tracks direkt von einem CD-Player adressiert werden,
+wobei ein Track mindestens 4 Sekunden lang sein muß. Die maximale Länge eines
+Tracks wird nur von der Länge der CD begrenzt. Einem Musikstück wird auf einer
+CD-DA ein Track zugeordnet.
+
+Die Audio-Daten einer CD-DA liegen grundsätzlich im PCM-Format vor.
+Der Aufbau einer CD gestaltet sich nun wie folgt. Generell
+muß der Audio-Datenstrom einer CD mit einem Mechanismus zur Fehlererkennung
+und Korrektur ausgestattet werden, sodaß eine gewisse Toleranz bei der
+Signal-Umwandlung gewährleistet ist. Bei CD-DA wird dabei ein Cross Interleave
+Reed-Solomon Code (CIRC) eingesetzt. Man nimmt also eine kleine Portion
+der Audio-Daten und versieht diese mit dem Fehlererkennungs- und
+-korrektur-Code.
+
+Diese kleine Portion ist mit 6 32-Bit-Samples bestimmt, was einer
+Audio-Datenmenge von 192 Bits entspricht. Diese Daten werden nun mit 64 CIRC
+Parity Bits, 8 Subcode Bits und 24 Sync-Bits erweitert, sodaß unsere Portion
+288 Bits breit ist. Eine solche Daten-Portion wird Frame genannt. 98 solcher
+Frames werden zu einem Block> oder auch Sektor zusammengefaßt. Bei einer
+Abtastrate von 44.1 kHz ergibt sich somit eine Framerate von 44.100 / 6 =
+7.350 Frames pro Sekunde. Zuguterletzt ergibt sich weiters die sog. Subcode
+block rate mit 7.350 / 98 = 75 Blocks pro Sekunde. Insgesammt werden für eine
+Sekunde der CD 2.116.800 Bits bzw. 264.600 Byte benötigt, wovon 176.400 Byte
+Audio-Daten sind. Dies resultiert also in einer Übertragungsrate von 1.411.200
+Bit/Sekunde (1.41 Mbit/sec).
+
+Betrachten wir die Einteilung der Daten in einem Block bzw. Sektor noch etwas
+genauer. Da ein Block aus 98 Frames besteht, transportiert jeder Block 2.352
+Bytes Nutzdaten, in diesem Fall reine Audio-Daten. Dazu kommen noch 882 Bytes
+für die beiden Ebenen des Fehlererkennungs- und -korrektur-Codes von CIRC
+(784) und die Kontroll-Bytes (98) sowie die Sync-Reihe mit 294 Bytes. Ein
+Block umfaßt also insgesammt 3.528 Bytes. Interessant sind hier vorallem die
+Kontrollbytes. Jedem Bit eines Kontroll-Bytes wird ein Buchstabe zugewiesen,
+"P", "Q", "R", "S", "T", "U", "V" und "W". Das erste Bit wird mit "P"
+bezeichnet, das zweite mit "Q" und so weiter. Der Datenstrom bestehend aus
+allen ersten Bits der 98 Kontroll-Bytes wird P-Subchannel genannt. Analog dazu
+bezeichnet man den Datenstrom aller zweiten Bits mit Q-Subchannel. Der dritte
+Datenstrom kombiniert die restlichen Bits "R", "S", "T", "U", "V" und "W" zu
+einem 6-Bit Wort und wird "R bis W"-Subchannel genannt.
+
+Der P-Subchannel enthält ein Flag (on/off), wenn ein Track beginnt. Der
+Q-Subchannel besteht aus den Zeitmarkierungen für die absolute und die
+relative Zeit. Im Lead-In enthält dieser Subchannel den Inhalt der CD (Table
+of contents, TOC). 72 der 98 Bits des Q-Subchannels werden für Informationen,
+der Rest zur Synchronisation, Kontrolle und Fehlerkorrektur der Subchannels
+genutzt. Neben den Bits für die Synchronisation, Kontrolle und Fehlerkorrektur
+kann der "R bis W"-Subchannel Benutzerdaten für zusätzliche Informationen
+enthalten (64 6-Bit Worte pro Block).
+
+So, nach soviel Zahlen- und Bit-Theorie machen wir uns an etwas handfesteres -
+die Adressierung von Tracks einer CD. Jeder Track auf einer CD wird
+grundsätzlich durch die Angabe von Minuten, Sekunden und Sektoren genau
+adressiert. Daraus ergibt sich ein interessanter Nebeneffekt bei der
+Berechnung der Spieldauer eines Tracks. Um nicht in die Verlegenheit zu
+geraten, sehr breite Fließkommazahlen im TOC einer CD zu halten, werden
+Zeitangaben in Minuten und Sekunden geführt. Natürlich geht sich nicht jeder
+Track auf eine ganze Sekundenzahl aus. In diesem Fall wird der verbleibende
+Rest in Sektoren angegeben. Da eine Sekunde wie bereits eingangs erklärt in 75
+Sektoren unterteilt wird, ergibt sich eine Genauigkeit von 0.01 Sekunden.
+
+Wie zu Beginn dieses Abschnittes bereits erwähnt muß jeder Track mindestens 4
+Sekunden lang sein. Diese Mindestlänge entspricht 300 Sektoren. Diesen Betrag
+an Sektoren teilen sich auch der Lead-In und Lead-Out, sodaß der erste Track
+beim Sektor 150 beginnt. Längenangaben können grundsätzlich auch in Sektoren
+gemacht werden.
+
+
+-> cd-extra cd's
+  - eine mixed-mode cd mit 2 sessions
+  - 1. session == alle audio tracks (weil cd-player nur 1.lesen)
+  - 2. session == alle daten
+
+-> mixed-mode cd's
+  - 1. track daten + 2-XX track == audio (nachfolger von cd-extra)
+  - ...
+
+-> cd-text
+  - in den subchannels r+w drinne
+  - subchannel q enthält z.b. verzeichnisstruktur....
+  - information @ftp://ftp.t10.org/t10/drafts/mmc2/mmc2r11a.pdf (last pages)
+
+
+-> subchannels
+  - P/Q/R/S/T/U/V/W mit je max. 4MB
+  - P/Q/R/W werden mehr oder weniger genutzt
+
+-- 
+Tino Reichardt
++ Stuff from http://www.all4freaks.org/
diff -urN mcd-0.1/docs/COPYING mcd-0.2/docs/COPYING
--- mcd-0.1/docs/COPYING	Sat Jun 16 04:05:11 2001
+++ mcd-0.2/docs/COPYING	Thu Jan  1 01:00:00 1970
@@ -1,340 +0,0 @@
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-		    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-			    NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-	    How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) year name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff -urN mcd-0.1/docs/README mcd-0.2/docs/README
--- mcd-0.1/docs/README	Sun Jul  8 15:22:15 2001
+++ mcd-0.2/docs/README	Thu Jan  1 01:00:00 1970
@@ -1,66 +0,0 @@
- WHAT IS IT
-===========
-
-- mcd is a small (maybe the smallest) cd-player for _linux_
-- it should compile/run out off the box
-- it compiles against the dietlibc
-
-
-
- REQUIREMENTS
-==============
-
-- linux >=2.2
-- /usr/include/termios.h (tcgetattr(),...)
-
-
-
- COPYING
-=========
-
-Copyright (C) 2000 Tino Reichardt <der@mcmilk.de>
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-AND
-
-Author strongly advices against using this code, or a part of it,
-in an application designed to run on any Microsoft(tm) platfrom.
-
-
-
- TODO
-======
-
-- term stuff, for better compatibility
-- term resizing stuff (via signal() ...)
-- better documentation ?
-- maybe an included help (key h is free)
-- manpage (maybe tn.stein@gmx.de?)
-- shuffle isn't implemented yet
-- but for now it works for me :P
-
-
- WISHLIST
-==========
-
-- CD-Text (i like this!)
-- maybe cddb (i don't like it much!)
-- maybe CD-Changer stuff, i don't know
-
-
-
- BUGS
-======
-
-Please report bugs to:
-
-  Tino Reichardt <milky-mcd@mcmilk.de>
diff -urN mcd-0.1/docs/README.de mcd-0.2/docs/README.de
--- mcd-0.1/docs/README.de	Sun Jul  8 15:07:37 2001
+++ mcd-0.2/docs/README.de	Thu Jan  1 01:00:00 1970
@@ -1,102 +0,0 @@
-siehe README !!!
-
-
-
-Technisches:
-
-
-CD-DA Standard alias RedBook
-============================
-
-Der Standard der Audio-CD (CD-DA) wurde also 1982 von Philips und Sony im
-RedBook definiert. Die maximale Spielzeit einer 12cm-CD beträgt 74 Minuten und
-33 Sekunden, eine 8cm Single-CD hat eine Laufzeit von etwa 21 Minuten. Auf
-einer CD können bis zu 99 Tracks direkt von einem CD-Player adressiert werden,
-wobei ein Track mindestens 4 Sekunden lang sein muß. Die maximale Länge eines
-Tracks wird nur von der Länge der CD begrenzt. Einem Musikstück wird auf einer
-CD-DA ein Track zugeordnet.
-
-Die Audio-Daten einer CD-DA liegen grundsätzlich im PCM-Format vor.
-Der Aufbau einer CD gestaltet sich nun wie folgt. Generell
-muß der Audio-Datenstrom einer CD mit einem Mechanismus zur Fehlererkennung
-und Korrektur ausgestattet werden, sodaß eine gewisse Toleranz bei der
-Signal-Umwandlung gewährleistet ist. Bei CD-DA wird dabei ein Cross Interleave
-Reed-Solomon Code (CIRC) eingesetzt. Man nimmt also eine kleine Portion
-der Audio-Daten und versieht diese mit dem Fehlererkennungs- und
--korrektur-Code.
-
-Diese kleine Portion ist mit 6 32-Bit-Samples bestimmt, was einer
-Audio-Datenmenge von 192 Bits entspricht. Diese Daten werden nun mit 64 CIRC
-Parity Bits, 8 Subcode Bits und 24 Sync-Bits erweitert, sodaß unsere Portion
-288 Bits breit ist. Eine solche Daten-Portion wird Frame genannt. 98 solcher
-Frames werden zu einem Block> oder auch Sektor zusammengefaßt. Bei einer
-Abtastrate von 44.1 kHz ergibt sich somit eine Framerate von 44.100 / 6 =
-7.350 Frames pro Sekunde. Zuguterletzt ergibt sich weiters die sog. Subcode
-block rate mit 7.350 / 98 = 75 Blocks pro Sekunde. Insgesammt werden für eine
-Sekunde der CD 2.116.800 Bits bzw. 264.600 Byte benötigt, wovon 176.400 Byte
-Audio-Daten sind. Dies resultiert also in einer Übertragungsrate von 1.411.200
-Bit/Sekunde (1.41 Mbit/sec).
-
-Betrachten wir die Einteilung der Daten in einem Block bzw. Sektor noch etwas
-genauer. Da ein Block aus 98 Frames besteht, transportiert jeder Block 2.352
-Bytes Nutzdaten, in diesem Fall reine Audio-Daten. Dazu kommen noch 882 Bytes
-für die beiden Ebenen des Fehlererkennungs- und -korrektur-Codes von CIRC
-(784) und die Kontroll-Bytes (98) sowie die Sync-Reihe mit 294 Bytes. Ein
-Block umfaßt also insgesammt 3.528 Bytes. Interessant sind hier vorallem die
-Kontrollbytes. Jedem Bit eines Kontroll-Bytes wird ein Buchstabe zugewiesen,
-"P", "Q", "R", "S", "T", "U", "V" und "W". Das erste Bit wird mit "P"
-bezeichnet, das zweite mit "Q" und so weiter. Der Datenstrom bestehend aus
-allen ersten Bits der 98 Kontroll-Bytes wird P-Subchannel genannt. Analog dazu
-bezeichnet man den Datenstrom aller zweiten Bits mit Q-Subchannel. Der dritte
-Datenstrom kombiniert die restlichen Bits "R", "S", "T", "U", "V" und "W" zu
-einem 6-Bit Wort und wird "R bis W"-Subchannel genannt.
-
-Der P-Subchannel enthält ein Flag (on/off), wenn ein Track beginnt. Der
-Q-Subchannel besteht aus den Zeitmarkierungen für die absolute und die
-relative Zeit. Im Lead-In enthält dieser Subchannel den Inhalt der CD (Table
-of contents, TOC). 72 der 98 Bits des Q-Subchannels werden für Informationen,
-der Rest zur Synchronisation, Kontrolle und Fehlerkorrektur der Subchannels
-genutzt. Neben den Bits für die Synchronisation, Kontrolle und Fehlerkorrektur
-kann der "R bis W"-Subchannel Benutzerdaten für zusätzliche Informationen
-enthalten (64 6-Bit Worte pro Block).
-
-So, nach soviel Zahlen- und Bit-Theorie machen wir uns an etwas handfesteres -
-die Adressierung von Tracks einer CD. Jeder Track auf einer CD wird
-grundsätzlich durch die Angabe von Minuten, Sekunden und Sektoren genau
-adressiert. Daraus ergibt sich ein interessanter Nebeneffekt bei der
-Berechnung der Spieldauer eines Tracks. Um nicht in die Verlegenheit zu
-geraten, sehr breite Fließkommazahlen im TOC einer CD zu halten, werden
-Zeitangaben in Minuten und Sekunden geführt. Natürlich geht sich nicht jeder
-Track auf eine ganze Sekundenzahl aus. In diesem Fall wird der verbleibende
-Rest in Sektoren angegeben. Da eine Sekunde wie bereits eingangs erklärt in 75
-Sektoren unterteilt wird, ergibt sich eine Genauigkeit von 0.01 Sekunden.
-
-Wie zu Beginn dieses Abschnittes bereits erwähnt muß jeder Track mindestens 4
-Sekunden lang sein. Diese Mindestlänge entspricht 300 Sektoren. Diesen Betrag
-an Sektoren teilen sich auch der Lead-In und Lead-Out, sodaß der erste Track
-beim Sektor 150 beginnt. Längenangaben können grundsätzlich auch in Sektoren
-gemacht werden.
-
-
--> cd-extra cd's
-  - eine mixed-mode cd mit 2 sessions
-  - 1. session == alle audio tracks (weil cd-player nur 1.lesen)
-  - 2. session == alle daten
-
--> mixed-mode cd's
-  - 1. track daten + 2-XX track == audio (nachfolger von cd-extra)
-  - ...
-
--> cd-text
-  - in den subchannels r+w drinne
-  - subchannel q enthält z.b. verzeichnisstruktur....
-  - information @ftp://ftp.t10.org/t10/drafts/mmc2/mmc2r11a.pdf (last pages)
-
-
--> subchannels
-  - P/Q/R/S/T/U/V/W mit je max. 4MB
-  - P/Q/R/W werden mehr oder weniger genutzt
-
--- 
-Tino Reichardt
-+ Stuff from http://www.all4freaks.org/
diff -urN mcd-0.1/docs/README.keys mcd-0.2/docs/README.keys
--- mcd-0.1/docs/README.keys	Sun Jul  8 15:21:04 2001
+++ mcd-0.2/docs/README.keys	Thu Jan  1 01:00:00 1970
@@ -1,32 +0,0 @@
-
- Keys
-======
-
-    Q/q.................quit program
-    M...................choose playmethod (+)
-    m...................choose playmethod (-)
-    R/r.................redraw screen, use after resizing
-    1234567890..........choose track
-    +...................choose trackmodifier (+)
-    -...................choose trackmodifier (-)
-    S/s.................Start/Stop (toggle)
-    P/p.................Pause/Resume (toggle)
-
-
- Arrows
-========
-    UP..................FastForward
-    DOWN................FastRewind
-    LEFT................SlowForward
-    RIGHT...............SlowRewind
-
-
- Note
-======
-    !! See also params.h, because some of them can be redefined. !!
-
-
-Please report bugs to:
-
-  Tino Reichardt <milky-mcd@mcmilk.de>
-
diff -urN mcd-0.1/draw.c mcd-0.2/draw.c
--- mcd-0.1/draw.c	Sun Jul  8 13:31:16 2001
+++ mcd-0.2/draw.c	Thu Jul 12 02:45:16 2001
@@ -6,11 +6,8 @@
  */
 #include "mcd.h"
 
-/* INTERN */
-
 static void draw_hline(int i, char *ch); /* draw an hline */
 static void draw_box(int x1, int y1, int x2, int y2); /* draw a box */
-static void draw_tracks(struct mcd *cd);
 static void draw_method(char *msg);
 
 static void draw_hline(int i, char *ch) {
@@ -18,6 +15,7 @@
  while (i!=1) {
   show1(ch);--i;
  }
+ return;
 }
 
 static void draw_box(int x1, int y1, int x2, int y2) {
@@ -29,15 +27,24 @@
   gotoxy(x2,y1+i);show1(AC_VL);
  }
  gotoxy(x1,y2);show1(AC_BL);draw_hline(x2-x1,AC_HL);show1(AC_BR);
+ return;
 }
 
-static void draw_tracks(struct mcd *cd) {
- register int i=1,m=1; /* title + modifier */
+
+static void draw_method(char *msg) {
+ gotoxy(11,5);
+ _printf(C_STATUS "%s" C_NORMAL, msg);
+ return;
+}
+
+
+/* GLOBAL */
+short maxx,maxy;  /* screenmaxima */
+
+void draw_tracks(struct mcd *cd) {
+ register int i=1,m=1; /* title/modifier/realtitle */
  int y=0,x=0; /* x,y==diffs to real */
 
- if ((cd->title[1]=cd_readtracks(&cd[0]))<1) {
-  draw_status("can't read tracks     ",1);return;
- }
  for (i=1;(i<=cd->title[1] && i<=99); i++) {
   m=((i-(pluskey+1)*10)<0 && (i-(pluskey+1)*10)>-11); /* is shortcut? */
   if (i%(maxy-10)==0) {y=-i;x+=15;} /* bottom reached, horiz. isn't checked! */
@@ -45,26 +52,19 @@
   if (m&&(i==cd->title[0])) _printf(C_STATUS "%02d" C_NORMAL, i); /* current */
   else if (m||(i==cd->title[0])) _printf(T_BOLD "%02d" C_NORMAL, i); /* current */
   else _printf("%02d",i); /* nothing special */
-
   if (i==cd->title[0]) show1(T_BOLD); /* current */
   _printf("%c - %02d:%02d\n",
    cd->t[i].audio?'d':'a',
    cd->t[i].min,
-   cd->t[i].sec,(i-(pluskey+1)*10),m);
+   cd->t[i].sec);
   if (i==cd->title[0]) show1(C_NORMAL); /* current */
  }
+
  gotoxy(13,10);
  _printf(C_STATUS "(%d)" C_NORMAL, pluskey);
+ return;
 }
 
-static void draw_method(char *msg) {
- gotoxy(11,5);
- _printf(C_STATUS "%-20s" C_NORMAL, msg);
-}
-
-
-/* GLOBAL */
-
 void draw_initscr(void) {
  draw_box(1,1,maxx,maxy);
  show1(C_BOX);
@@ -82,58 +82,72 @@
  show1(C_NORMAL);
 
  /* draw_box(30,2,maxx-1,8); for titel etc.. reseved */
+ return;
 }
 
-void draw_status(char *msg, short update) {
+void draw_status(char *msg, short again) {
  gotoxy(11,4);
- _printf(C_STATUS "%-20s" C_NORMAL, msg);
- if (update) {
+ _printf(C_STATUS "%-23s" C_NORMAL, msg);
+ if (again) {
   updates[U_STATUS]=1;
   sleep(1);
  }
+ return;
 }
 
 void draw_updatescr(struct mcd *cd) {
  if (cd_readsubchannel(cd)<0) {
-  havecd=0;
   draw_status("no disc",0);
  }
 
  show1(C_NORMAL);
- if (updates[U_ALL]==1) {
+ if (updates[U_ALL]) {
+  signal(SIGWINCH,tty_resize);
   clear();
   tty_getsize(&maxx,&maxy);
+  if (maxx<42 || maxy<13) {
+   show2("Sorry, you need at least a termsize of 42x13.\n");
+   tty_mode(TERM_QUIT);
+  }
+  if ((cd->title[1]=cd_readtracks(&cd[0]))<1) {
+   draw_status("can't read tracks",1);return;
+  }
+  /* last, but not least, init the shuffle tracks */
   draw_initscr();
+  cd_initshuffle(&cd[0]);
+  updates[U_TRACKS]=updates[U_STATUS]=updates[U_METHOD]=updates[U_VOLUME]=1;
   updates[U_ALL]=0;
  }
 
- if (updates[U_TRACKS]==1) {
- 
-  //cd_start(&cd[0]);
-  draw_tracks(cd);
-  updates[U_TRACKS]=0;
- }
-
- if (updates[U_STATUS]==1) {
+ if (updates[U_STATUS]) {
   draw_status(
-  (cd->cdstat[0]==CDROM_AUDIO_NO_STATUS) ? "no status              ":"" &&
-  (cd->cdstat[0]==CDROM_AUDIO_ERROR    ) ? "error                  ":"" &&
-  (cd->cdstat[0]==CDROM_AUDIO_COMPLETED) ? "completed              ":"" &&
-  (cd->cdstat[0]==CDROM_AUDIO_PAUSED   ) ? "paused                 ":"" &&
-  (cd->cdstat[0]==CDROM_AUDIO_PLAY     ) ? "playing                ":"" &&
-  (cd->cdstat[0]==CDROM_AUDIO_INVALID  ) ? "invalid                ":"",0);
+  (cd->status==CDROM_AUDIO_NO_STATUS) ? "no status":"" &&
+  (cd->status==CDROM_AUDIO_ERROR    ) ? "error    ":"" &&
+  (cd->status==CDROM_AUDIO_COMPLETED) ? "stopped  ":"" &&
+  (cd->status==CDROM_AUDIO_PAUSED   ) ? "paused   ":"" &&
+  (cd->status==CDROM_AUDIO_PLAY     ) ? "playing  ":"" &&
+  (cd->status==CDROM_AUDIO_INVALID  ) ? "invalid  ":"",0);
+  updates[U_STATUS]=0;
  }
 
- if (updates[U_METHOD]==1) {
+ if (updates[U_METHOD]) {
+  if (cd->method==M_SHUFFLE) {
+   cd_randomize(&cd[0]); updates[U_TRACKS]=1; /* shuffle in */
+  }
   draw_method(
-  (cd->method[0]==M_PLAY_CD)    ? "play cd     ":"" &&
-  (cd->method[0]==M_REPEAT_CD)  ? "repeat cd   ":"" &&
-  (cd->method[0]==M_REPEAT_TRK) ? "repeat track":"" &&
-  (cd->method[0]==M_SHUFFLE)    ? "shuffle     ":"" &&
-  (cd->method[0]==M_INTRO)      ? "intro       ":"");
+  (cd->method==M_PLAY_CD)    ? "play cd     ":"" &&
+  (cd->method==M_REPEAT_CD)  ? "repeat cd   ":"" &&
+  (cd->method==M_REPEAT_TRK) ? "repeat track":"" &&
+  (cd->method==M_SHUFFLE)    ? "shuffle     ":"" &&
+  (cd->method==M_INTRO)      ? "intro       ":"");
   updates[U_METHOD]=0;
  }
 
+ if (updates[U_TRACKS]) {
+  draw_tracks(&cd[0]);
+  updates[U_TRACKS]=0;
+ }
+
  show1(C_STATUS);
  if (updates[U_VOLUME]==1) {
   gotoxy(11,6);
@@ -143,14 +157,15 @@
 
  /* always */
  gotoxy(11,7);
- _printf("%02d:%02d (%d/%d)",
+ _printf("%02d:%02d (%2d/%2d)",
   cd->cds.cdsc_reladdr.msf.minute,
   cd->cds.cdsc_reladdr.msf.second,
   cd->title[0], cd->title[1]);
  gotoxy(11,8);
- _printf("%02d:%02d (%d/%d)",
+ _printf("%02d:%02d (%2d/%2d)",
   cd->cds.cdsc_absaddr.msf.minute,
-  cd->cds.cdsc_absaddr.msf.second, 1, 1); /* maybe more then one cd l8er */
- gotoxy(maxx-1,maxy-1);
+  cd->cds.cdsc_absaddr.msf.second,
+  1, 1); /* maybe more then one cd l8er */
+  gotoxy(2,2);
+ return;
 }
-
diff -urN mcd-0.1/formats.c mcd-0.2/formats.c
--- mcd-0.1/formats.c	Wed Jul  4 03:57:45 2001
+++ mcd-0.2/formats.c	Thu Jul 12 01:27:32 2001
@@ -58,43 +58,43 @@
       padwith=' ';
 
 inn_vsnprintf:
-      if (apos>=size) continue; /* ARGL !!! */
+if (apos>=size) continue; /* ARGL !!! */
 
       ch=*format++;
       switch (ch)
       {
 /* Format end ?!? */
       case 0:
-	return -1;
-	break;
+       return -1;
+       break;
 
 /* Format flag chars */
       case '#':
-	flag_hash=1;
-	goto inn_vsnprintf;
+        flag_hash=1;
+        goto inn_vsnprintf;
 
       case 'h':
-	--flag_long;
-	goto inn_vsnprintf;
+        --flag_long;
+        goto inn_vsnprintf;
       case 'l':
-	++flag_long;
-	goto inn_vsnprintf;
+        ++flag_long;
+        goto inn_vsnprintf;
 
       case '0':
-	padwith='0';
-	goto inn_vsnprintf;
+        padwith='0';
+        goto inn_vsnprintf;
 
       case '-':
-	flag_left=1;
-	goto inn_vsnprintf;
+        flag_left=1;
+        goto inn_vsnprintf;
 
       case ' ':
-	flag_space=1;
-	goto inn_vsnprintf;
+        flag_space=1;
+        goto inn_vsnprintf;
 
       case '+':
-	flag_sign=1;
-	goto inn_vsnprintf;
+        flag_sign=1;
+        goto inn_vsnprintf;
 
       case '1':
       case '2':
@@ -105,122 +105,122 @@
       case '7':
       case '8':
       case '9':
-	if(flag_dot) return -1;
-	width=strtol(--format,&pb,10);
-	format=pb;
-	goto inn_vsnprintf;
+        if(flag_dot) return -1;
+        width=strtol(--format,&pb,10);
+        format=pb;
+        goto inn_vsnprintf;
 
       case '*':
-	width=va_arg(arg_ptr,int);
-	goto inn_vsnprintf;
+        width=va_arg(arg_ptr,int);
+        goto inn_vsnprintf;
 
       case '.':
-	flag_dot=1;
-	if (*format=='*') {
-	  preci=va_arg(arg_ptr,int);
-	  ++format;
-	} else {
-	  preci=strtol(format,&pb,10);
-	  format=pb;
-	}
-	goto inn_vsnprintf;
+        flag_dot=1;
+        if (*format=='*') {
+          preci=va_arg(arg_ptr,int);
+          ++format;
+        } else {
+          preci=strtol(format,&pb,10);
+          format=pb;
+        }
+        goto inn_vsnprintf;
 
 /* Format conversion chars */
       case 'c':
-	ch=(char)va_arg(arg_ptr,int);
+        ch=(char)va_arg(arg_ptr,int);
       case '%':
-	if (str) str[apos]=ch; ++apos;
-	break;
+        if (str) str[apos]=ch; ++apos;
+        break;
 
       case 's':
-	pb=va_arg(arg_ptr,char *);
-	bu_len=strlen(pb);
-	if (flag_dot && bu_len>preci) bu_len=preci;
-	if ((unsigned long)bu_len>size-apos) bu_len=size-apos;
+        pb=va_arg(arg_ptr,char *);
+        bu_len=strlen(pb);
+        if (flag_dot && bu_len>preci) bu_len=preci;
+        if ((unsigned long)bu_len>size-apos) bu_len=size-apos;
 
 print_out:
-	if (str) {
-	  if (width && (!flag_left))
-	  {
-	    for (pad=width-bu_len; pad>0; --pad) str[apos++]=padwith;
-	  }
-	  for(i=0;i<(unsigned long)bu_len;++i) { str[apos++]=pb[i]; } /* strncpy */
-	  if (width && (flag_left))
-	  { /* left pad ALLWAYS with blanks ... */
-	    for (pad=width-bu_len; pad>0; --pad) str[apos++]=' ';
-	  }
-	} else {
-	  if (width) {
-	    apos+=width>bu_len?width:bu_len;
-	  } else {
-	    apos+=size>(unsigned long)bu_len?bu_len:size;
-	  }
-	}
+        if (str) {
+          if (width && (!flag_left))
+          {
+            for (pad=width-bu_len; pad>0; --pad) str[apos++]=padwith;
+          }
+          for(i=0;i<(unsigned long)bu_len;++i) { str[apos++]=pb[i]; } /* strncpy */
+          if (width && (flag_left))
+          { /* left pad ALLWAYS with blanks ... */
+            for (pad=width-bu_len; pad>0; --pad) str[apos++]=' ';
+          }
+        } else {
+          if (width) {
+            apos+=width>bu_len?width:bu_len;
+          } else {
+            apos+=size>(unsigned long)bu_len?bu_len:size;
+          }
+        }
 
-	break;
+        break;
 
-	/* Numbers */
+        /* Numbers */
       case 'b':
-	i=2;
-	goto num_vsnprintf;
+        i=2;
+        goto num_vsnprintf;
       case 'p':
-	flag_hash=1;
-	width=sizeof(void *)<<1;
-	padwith='0';
-	ch='x';
+        flag_hash=1;
+        width=sizeof(void *)<<1;
+        padwith='0';
+        ch='x';
       case 'X':
-	flag_upcase=(ch=='X');
+        flag_upcase=(ch=='X');
       case 'x':
-	i=16;
-	if (flag_hash)
-	{
-	  if (str) {
-	    str[apos++]='0';
-	    str[apos++]=ch;
-	  } else
-	    apos+=2;
-	}
-	goto num_vsnprintf;
+        i=16;
+        if (flag_hash)
+        {
+          if (str) {
+            str[apos++]='0';
+            str[apos++]=ch;
+          } else
+            apos+=2;
+        }
+        goto num_vsnprintf;
       case 'd':
       case 'i':
-	flag_in_sign=1;
+        flag_in_sign=1;
       case 'u':
-	i=10;
-	goto num_vsnprintf;
+        i=10;
+        goto num_vsnprintf;
       case 'o':
-	i=8;
-	if (flag_hash) { if (str) str[apos]='0'; ++apos; }
+        i=8;
+        if (flag_hash) { if (str) str[apos]='0'; ++apos; }
 
 num_vsnprintf:
-	if (apos>=size) continue; /* ARGL !!! */
+        if (apos>=size) continue; /* ARGL !!! */
 
-	if (flag_long>0) number=va_arg(arg_ptr,long);
-	else number=va_arg(arg_ptr,int);
+        if (flag_long>0) number=va_arg(arg_ptr,long);
+        else number=va_arg(arg_ptr,int);
 
-	if (flag_in_sign && (number<0))
-	{
-	  number=-number;
-	  flag_in_sign=2;
-	}
-	if (flag_long<0) number&=0xffff;
-	if (flag_long<-1) number&=0xff;
-	  bu_len=_ltostr(buf+1,sizeof(buf)-1,(unsigned long) number,i,flag_upcase);
-	pb=buf+1;
-
-	if (flag_in_sign==2)
-	{
-	  *(--pb)='-';
-	  bu_len++;
-	}
-	else if ((flag_in_sign)&&(flag_sign || flag_space))
-	{
-	  *(--pb)=(flag_sign)?'+':' ';
-	  bu_len++;
-	}
-	goto print_out;
+        if (flag_in_sign && (number<0))
+        {
+          number=-number;
+          flag_in_sign=2;
+        }
+        if (flag_long<0) number&=0xffff;
+        if (flag_long<-1) number&=0xff;
+          bu_len=_ltostr(buf+1,sizeof(buf)-1,(unsigned long) number,i,flag_upcase);
+        pb=buf+1;
+
+        if (flag_in_sign==2)
+        {
+          *(--pb)='-';
+          bu_len++;
+        }
+        else if ((flag_in_sign)&&(flag_sign || flag_space))
+        {
+          *(--pb)=(flag_sign)?'+':' ';
+          bu_len++;
+        }
+        goto print_out;
 
       default:
-	break;
+        break;
       }
       break;
     case 0:
diff -urN mcd-0.1/mcd.1 mcd-0.2/mcd.1
--- mcd-0.1/mcd.1	Thu Jan  1 01:00:00 1970
+++ mcd-0.2/mcd.1	Thu Jul 12 00:50:27 2001
@@ -0,0 +1,46 @@
+.\" Tino Reichardt <der@mcmilk.de>
+.TH MCD 1 "2001-07-10" "" "User commands"
+.SH "NAME"
+mcd \- a small cdplayer for linux
+.SH "SYNOPSIS"
+\fBmcd\fR [\fI/dev/some-cdrom-device\fR]
+.SH "DESCRIPTION"
+The command \fBmcd\fR is used for playing AudioCD's. It has a curses like
+userinterface and is fairly simple to use.
+.SH "KEYS"
+.TS
+tab (@);
+l l.
+#@play track number # (0,1..9)
+cursor up@fast forward
+cursor right@slow forward
+cursor left@slow rewind
+cursor down@fast rewind
+</>@change volume (-/+)
++/-@change trackmodifier (+/-)
+space@next track
+b/B@previous track
+M/m@change playmethod (-/+)
+S/s@toggle start/stop
+P/p@toggle pause/resume
+E/e@eject cdrom device
+C/c@close cdrom device
+R/r@redraw screen and reinit shuffle
+Q/q@quit mcd
+.TE
+.SH "RETURN VALUE"
+.TS
+tab (@);
+l l.
+\fB0\fP @if no errors occured
+\fB1\fP @if some error occured
+.TE
+.SH "NOTES"
+Some terminals don't like the default escape-sequences from params.h ... if
+so, you have to edit them !
+.PP
+Successfully tested terminals are:
+.B vt100,
+.B linux,
+.B xterm,
+.B xterm-color
diff -urN mcd-0.1/mcd.c mcd-0.2/mcd.c
--- mcd-0.1/mcd.c	Sun Jul  8 15:06:58 2001
+++ mcd-0.2/mcd.c	Thu Jul 12 02:44:53 2001
@@ -6,34 +6,12 @@
  */
 #include "mcd.h"
 
-short pluskey=0; /* 0..9 -> track XN is played */
-short maxx,maxy; /* screenmaxima */
-
-/* 0=status 1=method 2=volume 3=tracks 4=cd-change(l8er)
- * 4=ALL (times,pluskey always!)
- */
-short updates[5];
-short havecd;
-
-void mcd_init(void) {
- tty_mode(TERM_INIT);
- clear();
- tty_getsize(&maxx,&maxy);
- if (maxx<60 || maxy<15) {
-  show2("Sorry, you need at least a termsize of 60x15.\n");
-  tty_mode(TERM_QUIT);
- }
-}
-
-void mcd_quit(void) {
- show1(T_NORMAL);clear();
- show_b("ByeBye...\n\n");
- tty_mode(TERM_QUIT);
-}
+short pluskey=0;  /* 0..9|X is played */
+short updates[5]; /* see mcd.h */
 
 int main(int argc, char **argv, char **environ) {
  struct mcd *cd=malloc(sizeof(struct mcd));
- int quit=0,i;
+ int quit=0;
  char ch;
 
  if (argc>1) quit=cd_init(argv[1],&cd[0]);
@@ -46,45 +24,61 @@
   case -1:
    _printf("Sorry, can't open cd-device: \"%s\" !\n",(argc>1)?argv[1]:CDROM_DEFAULT);
    exit(1);
-   break;
  }
- havecd=1;
- mcd_init();
- draw_initscr();
- for (i=0;i<=5;i++) updates[i]=1;
+ tty_mode(TERM_INIT);
+ signal(SIGINT,mcd_quit);
+ signal(SIGQUIT,mcd_quit);
+ signal(SIGTERM,mcd_quit);
 
- for (;!quit;) {
+ updates[U_ALL]=1;
+ while (!quit) {
   draw_updatescr(&cd[0]);
   if (1 == select_wait(0,1)) {
    read(0,&ch,1);
    switch (ch) {
-  /* m=method s=start/stop(real) p=pause/resume
-   * q=quit e=eject c=close r=resize (+signal l8er)
-   * <>= volume  (+/-)=track +/-  cursor=ff/fw/..
-   * maybe editing in later times :)
-   */
    case '\033':
     read(0,&ch,1);read(0,&ch,1); /* XXX - should be done in another way ? */
     switch(ch) {
-     case 'A': cd_skip(&cd[0], FW_FAST);break; /*t*/
-     case 'B': cd_skip(&cd[0],-RW_FAST);break; /*b*/
-     case 'C': cd_skip(&cd[0], FW_SLOW);break; /*l*/
-     case 'D': cd_skip(&cd[0],-RW_SLOW);break; /*r*/
+     case 'A': cd_skip(&cd[0], FW_FAST);break; /* c_up */
+     case 'B': cd_skip(&cd[0],-RW_FAST);break; /* c_down */
+     case 'C': cd_skip(&cd[0], FW_SLOW);break; /* c_left */
+     case 'D': cd_skip(&cd[0],-RW_SLOW);break; /* c_right */
     }
     break;
+   case ' ': /* next */
+    cd->title[0]++;cd_start(&cd[0]);
+    updates[U_TRACKS]=1;
+    break;
+   case 'b': /* previous */
+   case 'B':
+    cd->title[0]--;cd_start(&cd[0]);
+    updates[U_TRACKS]=1;
+    break;
    case 'r':
    case 'R':
-    for (i=0;i<=5;i++) updates[i]=1;
+    updates[U_ALL]=1;
     break;
    case 'm':
-    updates[U_METHOD]=1;
-    if (cd->method[0]<M_INTRO) cd->method[0]++;
-    else cd->method[0]=M_PLAY_CD;
+    if (cd->method==M_SHUFFLE) { /* out of shuffle */
+     cd->method++;
+     cd_randomize(&cd[0]);
+     updates[U_TRACKS]=updates[U_METHOD]=1;
+     break;
+    }
+    if (cd->method<M_INTRO) cd->method++;
+    else cd->method=M_PLAY_CD;
+    updates[U_TRACKS]=updates[U_METHOD]=1;
     break;
    case 'M':
+    if (cd->method==M_SHUFFLE) { /* out of shuffle */
+     cd->method--;
+     cd_randomize(&cd[0]);
+     updates[U_TRACKS]=updates[U_METHOD]=1;
+     break;
+    }
+    if (cd->method>M_PLAY_CD) cd->method--;
+    else cd->method=M_INTRO;
     updates[U_METHOD]=1;
-    if (cd->method[0]>M_PLAY_CD) cd->method[0]--;
-    else cd->method[0]=M_INTRO;
     break;
    case 'P':
    case 'p':
@@ -93,19 +87,21 @@
     break;
    case 'S':
    case 's':
-    if (cd->cdstat[0]==CDROM_AUDIO_PLAY) cd_stop(&cd[0]);
-    else {cd->title[0]=1;cd_start(&cd[0]);}
-    updates[U_STATUS]=1;
+    if (cd->status==CDROM_AUDIO_PLAY) {
+     cd_stop(&cd[0]);
+    } else {
+     cd->title[0]=1;
+     cd_start(&cd[0]);
+    }
+    updates[U_STATUS]=updates[U_TRACKS]=1;
     break;
    case 'E':
    case 'e':
     cd_eject(&cd->fd);
-    updates[U_TRACKS]=updates[U_STATUS]=1;
     break;
    case 'C':
    case 'c':
     cd_close(&cd->fd);
-    updates[U_TRACKS]=updates[U_STATUS]=1;
     break;
    case '+':
     pluskey=(pluskey<9)?++pluskey:0;
@@ -119,14 +115,14 @@
     cd->vol.channel0=cd->vol.channel1=cd->vol.channel2=cd->vol.channel3=
      (cd->vol.channel0>0)?cd->vol.channel0-=3:255;
     if (ioctl(cd->fd,CDROMVOLCTRL,&cd->vol)<0)
-     draw_status("error, setting volume ",1);
+     draw_status("error, setting volume",1);
     updates[U_VOLUME]=1;
     break;
    case '>':
     cd->vol.channel0=cd->vol.channel1=cd->vol.channel2=cd->vol.channel3=
      (cd->vol.channel0<255)?cd->vol.channel0+=3:0;
     if (ioctl(cd->fd,CDROMVOLCTRL,&cd->vol)<0)
-     draw_status("error, setting volume ",1);
+     draw_status("error, setting volume",1);
     updates[U_VOLUME]=1;
     break;
    case 'q':
@@ -149,11 +145,17 @@
      cd->title[0]=((pluskey*10)+((int)ch-48));
      cd_start(&cd[0]);
     }
-    updates[U_TRACKS]=updates[U_STATUS]=1;
+    updates[U_TRACKS]=1;
     break;
    }
   }
  }
- mcd_quit(); /* cleanup */
+ mcd_quit(1); /* cleanup */
  exit(0);
+}
+
+void mcd_quit(int i) {
+ show1(C_NORMAL);clear();
+ show1(T_BOLD "ByeBye...\n\n" T_NORMAL);
+ tty_mode(TERM_QUIT);
 }
diff -urN mcd-0.1/mcd.h mcd-0.2/mcd.h
--- mcd-0.1/mcd.h	Sun Jul  8 13:39:44 2001
+++ mcd-0.2/mcd.h	Thu Jul 12 02:23:14 2001
@@ -7,23 +7,24 @@
 #ifndef _MCD_H
 #define _MCD_H
 
-#include <unistd.h>
+#include <time.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <string.h>
 #include <stdarg.h>
 #include <termios.h>
 #include <signal.h>
 
+#include <sys/time.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/fcntl.h>
-#include <sys/time.h>
 
 #include <linux/cdrom.h>
 
 #include "params.h"
 
-#define MCD_VERSION "0.1"
+#define MCD_VERSION "0.2"
 
 /* METHODS (don't change!) */
 #define M_PLAY_CD	0	/* play whole cd and stop */
@@ -32,42 +33,37 @@
 #define M_SHUFFLE	3	/* play some random tracks */
 #define M_INTRO		4	/* play first ten seconds of each track and stop */
 
-
 /* for selected refresh (times are always refr..) */
 #define U_STATUS	0 /* only titles are updated */
 #define U_METHOD	1 /* status-method is updated */
 #define U_VOLUME	2 /* status-volume is updated */
 #define U_TRACKS	3 /* all tracks are updated */
-#define U_CDCHANGE	4 /* ... reserved */
+#define U_CDCHANGER	4 /* ... reserved */
 #define U_ALL		5 /* really ALL is updated */
 
-
 /* ***** */
 /* mcd.c */
 struct track {
+ int nr;    /* title number */
+ int rnd;   /* random title */
  int audio; /* current track is audio */
  int sec;   /* seconds of current title */
  int min;   /* minutes of current title */
 };
 
 struct mcd {
- int fd;          /* file descriptor */
-
- /* maybe i need all this @l8er times :) */
- int method[1];   /* current/old playing METHOD (M_*) */
- int cdstat[1];   /* current/old DISC_STATUS  (from linux/cdrom.h) */
- int discstat[1]; /* current/old DRIVE_STATUS (from linux/cdrom.h) */
- int title[1];    /* current/last playable title */
-
+ int fd;       /* file descriptor */
+ int method;   /* current playing METHOD (M_*) */
+ int status;   /* old status, compared to cds.audiost.. */
+ int title[1]; /* current/last title */
  struct track t[MCD_CDAUDIO_MAX+1]; /* calculated times of all tracks */
  struct cdrom_volctrl vol;          /* current channel0..3 (0..255) */
  struct cdrom_subchnl cds;          /* tmp subchannelinfos */
  struct cdrom_tocentry cdte[MCD_CDAUDIO_MAX+1]; /* for playmsf */
 };
 
-extern short maxx,maxy,pluskey,updates[5],havecd;
-extern void mcd_init(void);	/* init screen + default cd */
-extern void mcd_quit(void);	/* cleanups + quit */
+extern short maxx,maxy,pluskey,updates[5];
+extern void mcd_quit(int);	/* cleanups + quit */
 
 /* ***** */
 /* tty.c */
@@ -75,14 +71,11 @@
 #define TERM_QUIT 1 /* reset terminal to the old values */
 extern void tty_mode(int mode); /* for setting up the terminal */
 extern int  tty_getsize(short *x, short *y); /* termsize to x,y */
-extern void tty_resize(short x, short y); /* after changes */
+extern void tty_resize(int i); /* after changes */
 
 /* aliase */
 #define show1(m)	mesg(1,(char*)m) /* to stdout */
 #define show2(m)	mesg(2,(char*)m) /* to stderr */
-#define show_b(a)	show1(T_BOLD a C_NORMAL)
-#define show_u(a)	show1(T_UNDERL a C_NORMAL)
-#define show_i(a)	show1(T_INVERSE a C_NORMAL)
 
 #define clear()		show1(T_HOME T_CLEAR)
 #define gotoxy(x,y)	_printf(T_GOTO_XY, y, x)
@@ -93,6 +86,7 @@
 extern void draw_initscr(void);
 extern void draw_updatescr(struct mcd *cd);
 extern void draw_status(char *msg, short update);
+extern void draw_tracks(struct mcd *cd);
 
 /* ****** */
 /* misc.c */
@@ -111,6 +105,8 @@
 extern void cd_stop(struct mcd *cd);
 extern void cd_eject(int *fd);
 extern void cd_close(int *fd);
+extern void cd_initshuffle(struct mcd *cd);
+extern void cd_randomize(struct mcd *cd);
 
 /* ********* */
 /* formats.c */
diff -urN mcd-0.1/params.h mcd-0.2/params.h
--- mcd-0.1/params.h	Sun Jul  8 14:27:18 2001
+++ mcd-0.2/params.h	Wed Jul 11 11:18:54 2001
@@ -5,7 +5,7 @@
 #ifndef _MCD_PARAMS_H
 #define _MCD_PARAMS_H
 
-#define CDROM_DEFAULT   "/dev/cdrom1"
+#define CDROM_DEFAULT   "/dev/cdrom"
 
 /* seconds for the intro */
 #define MCD_INTRO_TIME  10
@@ -21,16 +21,15 @@
 
 
 /*
- * seqences, you may change some of them ...
+ * ESC seqences, you may change some of them ...
  * (these are vt100, xterm, linux, xterm-color compatible)
  */
+
+/* needed */
 #define T_NORMAL  "\033[0m"        /* normal mode */
 #define T_BOLD    "\033[1m"        /* bold mode */
-#define T_INVERSE "\033[7m"        /* inverse mode */
 #define T_HOME    "\033[H"         /* goto 0,0 */
 #define T_CLEAR   "\033[2J"        /* clear screen */
-#define T_SAVE_C  "\0337"          /* save cursor position */
-#define T_JUMP_C  "\0338"          /* goto saved cursor position */
 #define T_GOTO_XY "\033[%d;%dH"    /* goto x,y position (%d=int) */
 
 /* box drawing */
@@ -46,19 +45,16 @@
 #define AC_HL  "\016q\017"         /* hline - */
 #define AC_VL  "\016x\017"         /* vline | */
 
-
-/* colors for mcd:
- *
- * ESC[%d;%d;%dm (style/fg/bg)
- * style: 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
- * fg: 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=grey
- * bg: 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=grey
- */
+/* colors */
 #define C_BOX       "\033[0;34m"  /* blue   - boxdrawing */
 #define C_NORMAL    "\033[0;37m"  /* grey   - normal/default/tracks */
 #define C_STATUS    "\033[0;31m"  /* red    - stausline (track++) */
 #define C_DESCRIPT  "\033[1;33m"  /* yellow - descriptions */
 #define C_HEADLINE  "\033[0;33m"  /* brown  - version, headlines */
+/* style: 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
+ * fg: 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=grey
+ * bg: 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=grey
+ */
 
 
 #endif /* _MCD_PARAMS_H */
diff -urN mcd-0.1/tty.c mcd-0.2/tty.c
--- mcd-0.1/tty.c	Sat Jul  7 10:37:48 2001
+++ mcd-0.2/tty.c	Thu Jul 12 02:14:44 2001
@@ -31,21 +31,19 @@
    exit(1);
   }
   exit(0);
- default: return;
  }
+ return;
 }
 
-void tty_resize(short x, short y) {
- clear();
- /* plus enything else ... */
+void tty_resize(int i) {
+ updates[U_ALL]=1;
 }
 
 int tty_getsize(short *x, short *y) {
  volatile struct winsize ws;
 
  if (ioctl(1, TIOCGWINSZ, &ws)!=-1) {
-  *x = ws.ws_col;
-  *y = ws.ws_row;
+  *x = ws.ws_col; *y = ws.ws_row;
   return 0;
  }
  show2("Can't get Terminalsize.");
