]> git.lizzy.rs Git - plan9front.git/blob - sys/src/games/music/readcd
games/snes: added open bus emulation
[plan9front.git] / sys / src / games / music / readcd
1 #!/bin/rc
2
3 cdrom=/dev/sdC1
4
5 switch($#*){
6 case 3
7         starttrack = `{echo $1 - 1 | hoc}
8         endtrack = `{echo $2 - 1 | hoc}
9         desttrack = $3
10 case *
11         echo Usage readcd starttrack endtrack desttrack
12 }
13
14 if(test -e /mnt/cd/ctl){
15         echo -n ingest >/mnt/cd/ctl >[2]/dev/null
16 }
17 if not {
18         if (~ $cdrom '')        cdfs
19         if not          cdfs -d $cdrom
20 }
21
22 >/tmp/readcd
23 >/tmp/map
24 cat /mnt/cd/ctl
25 sed 1q /mnt/cd/ctl | rc
26 echo $starttrack $endtrack $desttrack | awk '{
27         start = $1
28         finish = $2
29         dest = $3
30         print "read cd tracks " start "-" finish " starting at " dest
31         for (i = start; i <= finish; i++) {
32                 cmd = sprintf("ls -l /mnt/cd/a%3.3d | awk ''{print $6}''>>/tmp/readcd", i)
33                 system(cmd)
34                 getline x<"/tmp/readcd"
35                 sec = x/44100/4
36                 min = sec/60
37                 sec = sec%60
38                 printf("track {\n\t\n\tfile {%3.3d}\n\ttime {%d:%2.2d}\n}\n",i+dest-start,min,sec)>"/tmp/map"
39         }
40         for (i = start; i <= finish; i++) {
41                 cmd = sprintf("/bin/games/pacenc /mnt/cd/a%3.3d %3.3d",i,i+dest-start)
42                 print cmd
43                 system(cmd)
44         }
45 }'
46 echo eject >/mnt/cd/ctl