home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fun CD 26
/
OTACD26.ISO
/
archive
/
game
/
nnirowave
/
nnirowave.lzh
/
nnirowave
/
nnirowave.c
next >
Wrap
C/C++ Source or Header
|
1997-12-30
|
8KB
|
357 lines
/* クイズなないろドリームス 音声ローダ Ver.0.8 */
/* 97/7/29 (c)tokai@main.eng.hokudai.ac.jp */
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
void wlong(long),wshort(short);
FILE *fo,*fi;
// 入力ファイル名の作成
char* cinput(char drive,int path ,char *head,int n)
{
char *out
,num[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}
,*path2[13]={
":\\GL00_PCM\\",":\\GL01_PCM\\",":\\GL02_PCM\\",":\\GL03_PCM\\",":\\GL04_PCM\\",
":\\GL05_PCM\\",":\\GL06_PCM\\",":\\GL07_PCM\\",":\\GL08_PCM\\",":\\GL09_PCM\\",
":\\GL0A_PCM\\",":\\END_PCM\\",":\\"};
int i=0,i2=0,length,leng=-1;
while(path2[path][++leng]!='\0');
length =leng + 10;
if((out = (char *)malloc(length*sizeof(char)))==0){
printf("error in cinput\n");exit(1);}
out[0] = drive;
for(i=1;i<=leng;i++) out[i] = path2[path][i-1];
out[i++]=head[0]; out[i++]=head[1];
i2 = n /16; n -= i2*16;
out[i++]=num[i2];out[i++]=num[n];
out[i++]='.';out[i++]='M';out[i++]='U';out[i++]='S';out[i]='\0';
return(out);
}
//出力ファイル名の作成
char* coutput(int chara,int n){
char *out
,*chara2[15]={"kumiko_","momoko_","rotte_","saki_","mayumi_","emi_",
"megumi_","rintu_","maou_","yosei_","effect_","end_",
"opening_","omake_","aisatu_"};
int i,i2,i3,leng=-1,length;
while(chara2[chara][++leng]!='\0');
length = leng + 7;
if((out = (char *)malloc(length*sizeof(char)))==0){
printf("error in cinput\n");exit(1);}
i2 = n /100; n -= i2*100; i2 += 48;
i3 = n /10; n -= i3*10; i3 += 48;
n += 48;
for(i=0;i<leng;i++) out[i] = chara2[chara][i];
out[i++]=i2;out[i++]=i3;out[i++]=n;
out[i++]='.';out[i++]='w';out[i++]='a';out[i++]='v';out[i]='\0';
return(out);
}
main(int argc,char *argv[])
{
int i,i2,c1,c2,chara,path,from,to;
int size,chn,freq,bit;
int chr[15]={115,114,124,165,127,101,182,107,59,292,11,185,18,9,10};
char *file,*ofile,*file2[300],drive,*head;
freq = 38000; chn=1; bit = 16;
printf("CDの入っているドライブ名を入力して下さい。\n(例)ドライブ A なら a \n\n? ");
scanf("%c",&drive);
printf("\n抜き出すファイルの種類を選んで下さい。\n\n0:久美子音声 1:桃子音声 2:ロッテ音声 3:サキ音声 4:真由美音声\n5:絵美音声 6:めぐみ音声 7:リンツ音声 8:魔王音声 9:妖精(その他)音声\n10:各種効果音 11:エンディング音声 12:オープニング音声 13:おまけ音声\n14:あいさつ音声\n\n? ");
scanf("%d",&chara);
if(chara <0 || chara > 14)
{printf("正しい範囲を指定して下さい。");exit(1);}
if(chara != 13){
printf("\n存在するファイルの数は %d 個です。抜き出す範囲を指定して下さい。\n(例)30番から39番まで10個のファイルを抜き出す時は from? 30 to? 39\n\n",chr[chara]);
printf("from? ");scanf("%d",&from);
printf("to? ");scanf("%d",&to);
if(from <1 || from > to || to > chr[chara])
{printf("正しい範囲を指定して下さい。");exit(1);} }
switch(chara){
case 0: //kumiko
head="00";path = chara;
for(i=from;i<=to;i++){
i2 = i+12-1;
file2[i] = cinput(drive,path,head,i2); }
break;
case 1: //momoko
head="01";path = chara;
for(i=from;i<=to;i++){
i2 = i+17-1;
file2[i] = cinput(drive,path,head,i2); }
break;
case 2: //rotte
path = chara;
for(i=from;i<=to;i++){
if(i<123){
head="02";
i2 = i+14-1;}
else{
head="0D";
i2 = i-123;}
file2[i] = cinput(drive,path,head,i2); }
break;
case 3: //saki
path = chara;
for(i=from;i<=to;i++){
if(i<164){
head="03";
i2 = i+17-1;}
else{
head="0B";
i2 = i-164;}
file2[i] = cinput(drive,path,head,i2); }
break;
case 4: //mayumi
path = chara;
head="04";
for(i=from;i<=to;i++){
if(i<83) i2 = i+13-1;
else i2 = i-83+115;
file2[i] = cinput(drive,path,head,i2); }
break;
case 5: //emi
path = chara;
for(i=from;i<=to;i++){
if(i<=92){
head="05";
if(i<=45) i2 = i+17-1;
else if(i<=77)i2 = i-46+74;
else if(i==78)i2 = 113;
else i2 = i - 79 + 123;}
else{
head="0A"; path = 9;
i2 = i - 93 + 95;}
file2[i] = cinput(drive,path,head,i2); }
break;
case 6: //megumi
path = chara;
for(i=from;i<=to;i++){
if(i<=180){
head="06";
if(i<=109) i2 = i+14-1;
else i2 = i - 110 + 150;}
else{
head="0C";
i2 = i -181;}
file2[i] = cinput(drive,path,head,i2); }
break;
case 7: //rintu
path = chara;
head="07";
for(i=from;i<=to;i++){
if(i<=28) i2 = i-1;
else if(i<=92) i2 = i-29+42;
else i2 = i - 93 + 119;
file2[i] = cinput(drive,path,head,i2); }
break;
case 8: //mao
path = chara;
head="08";
for(i=from;i<=to;i++){
if(i<=57) i2 = i-1;
else i2 = i - 58 + 254;
file2[i] = cinput(drive,path,head,i2); }
break;
case 9: //yosei
path = chara;
for(i=from;i<=to;i++){
if(i<=215){
head="09";
if(i<=104) i2 = i-1;
else i2 = i-105+145;}
else{
head="0A";
if(i<=241) i2 = i-216;
else if(i<=290) i2 = i - 242 + 46;
else i2 = i - 291 + 252;}
file2[i] = cinput(drive,path,head,i2); }
break;
case 10: //effect
for(i=from;i<=to;i++){
if (i<=9){
head="0F";
i2 = i -1;
if (i<=2) path = 4;
else if(i==3) path = 0;
else if(i<=5) path = 3;
else path = 4;}
else{
head="0A";
i2 = i - 10 + 254;
path = 6;}
file2[i] = cinput(drive,path,head,i2); }
break;
case 11: //ending
path = chara;
head="0E";
for(i=from;i<=to;i++){
if(i<=111) i2 = i-1;
else i2 = i - 112 + 118;
file2[i] = cinput(drive,path,head,i2); }
break;
case 12: //opening
path = 12;
head="09";
for(i=from;i<=to;i++){
i2 = i-1+ 111;
file2[i] = cinput(drive,path,head,i2); }
break;
case 13: //omake
printf("\nキャラクターを選んで下さい。\n\n1:久美子 2:桃子 3:シャルロッテ\n4:サキ 5:真由美 6:絵美\n7:めぐみ 8:妖精 9:リンツ\n\n");
printf("? ");scanf("%d",&from);
if(from <1 || from > 9)
{printf("正しい範囲を指定して下さい。");exit(1);}
to=from;
path = 12;
head="0F";
for(i=from;i<=to;i++){
i2 = i-1+ 128;
file2[i] = cinput(drive,path,head,i2); }
break;
case 14: //aisatu
path = 12;
head="0F";
for(i=from;i<=to;i++){
i2 = i-1+ 137;
file2[i] = cinput(drive,path,head,i2); }
break;
default:
printf("正しい番号を入力して下さい");
exit(1);
}
for(i=from;i<=to;i++){
/* check input file size */
file = file2[i];
fprintf(stderr,"\n-- No.%d -- file name = %s\ncheckig size .",i,file);
size = 0;
if((fi = fopen(file,"rb"))==0){
printf("\nfile not found %s\n",file);exit(1);}
while(fgetc(fi)!=-1) {
size++;
if(size%51200==0)fprintf(stderr,".");}
fclose(fi);
fprintf(stderr,"ok.\nsize = %d byte\n\n",size);
/* open output file */
ofile = coutput(chara,i);
fprintf(stderr,"writing file %s .",ofile);
if((fo = fopen(ofile,"wb"))==0){
printf("\nfile write errror %s\n",ofile);exit(1);}
/* reopen input file */
if((fi = fopen(file,"rb"))==0){
printf("\nfile not found %s\n",file);exit(1);}
fputc('R',fo);
fputc('I',fo);
fputc('F',fo);
fputc('F',fo);
wlong((long)(size+36));
fputc('W',fo);
fputc('A',fo);
fputc('V',fo);
fputc('E',fo);
fputc('f',fo);
fputc('m',fo);
fputc('t',fo);
fputc(' ',fo);
wlong(16l);
wshort(1);
wshort((short)chn);
wlong((long)freq);
wlong((long)(freq*bit/8*chn));
wshort((short)(bit/8*chn));
wshort((short)bit);
fputc('d',fo);
fputc('a',fo);
fputc('t',fo);
fputc('a',fo);
wlong((long)size);
for(i2=0;i2<size;i2+=bit/8*chn){
if(i2%51200==0)fprintf(stderr,".");
c1=fgetc(fi); c2=fgetc(fi);
fputc(c2,fo);fputc(c1,fo);}
fprintf(stderr,"done.\n");
fclose(fi);
fclose(fo);
}
return(1);
}
void wshort(short n)
{
fputc(n & 255,fo);
fputc((n >> 8)&255,fo);
}
void wlong(long n)
{
fputc((int)(n & 255),fo);
fputc((int)((n >> 8) & 255),fo);
fputc((int)((n >> 16)& 255),fo);
fputc((int)((n >> 24)& 255),fo);
}