const char* get_png_filename(const char* raw_filename) { static char filename[128]; /* 4 = strlen(".png") */ strncpy(filename, raw_filename, sizeof(filename) - 4 - 1); filename[sizeof(filename) - 4] = '\0'; remove_ext(filename, ".gz"); remove_ext(filename, ".raw"); strcat(filename, ".png"); return filename; }
void change_ext(char *input, char *output, char *ext) { char *tmp_file; if (!strcmp(output, "")) { tmp_file = remove_ext(input, '.', '/'); strcpy(output, tmp_file); strcat(output, ext); free(tmp_file); } }
const char* get_raw_filename(const char* png_filename, int compress) { static char filename[128]; /* 7 = strlen(".raw.gz") */ strncpy(filename, png_filename, sizeof(filename) - 7 - 1); filename[sizeof(filename) - 7] = '\0'; remove_ext(filename, ".png"); strcat(filename, compress ? ".raw.gz" : ".raw"); return filename; }
int main(int argc, char **argv) { struct arguments arguments; /* Default values. */ arguments.silent = 0; arguments.verbose = 0; /* Parse our arguments; every option seen by parse_opt will be reflected in * arguments. */ argp_parse(&argp, argc, argv, 0, 0, &arguments); char *real_path = realpath("./", NULL); /* Create output folder */ char *output_folder = remove_ext(arguments.args[0], '.', '/'); struct stat st = {0}; if (stat(output_folder, &st) == -1) { mkdir(output_folder, 0700); } struct DAR_ARCHIVE *archive = openArchive(arguments.args[0]); for (uint32_t index = 0; index < archive->count; index++) { // Output file name const size_t path_size = strlen(output_folder) + strlen(archive->entries[index].name) + 2; char *path = malloc(path_size); // Build output filename snprintf(path, path_size, "%s/%s", output_folder, archive->entries[index].name); // Write file FILE *write_ptr = fopen(path, "wb"); fwrite(archive->entries[index].data, archive->entries[index].size, 1, write_ptr); // Free resources fclose(write_ptr); free(path); } return 0; // struct DAR_ARCHIVE *archive = // openArchive("/home/dustin/.wine/drive_c/Program Files (x86)/Metal Gear // Solid/stage/s19br/stg_tex1.dar"); }
int main(int argc, char **argv) { extern int yydebug; yydebug = 1; if (argc < 2) { fprintf(stderr,"Utilize o comando da seguinte forma: compilador.tge filename -options\n"); exit(1); } char *filename = argv[1]; A_exp prg = parse(filename); int IS_ERRORS; if (prg != NULL) { printf("\n[ ANALISE SINTATICA ] Completada!! :) \n"); printf("[ ANALISE SEMANTICA ] Iniciando!\n"); SEM_transProg(prg, &IS_ERRORS); printf("[ ANALISE SEMANTICA ] Completada! :D \n"); }else{ printf("[ ANALISE SEMANTICA ] Não entrou! (ಠ_ಠ) \n"); } if(!IS_ERRORS){ char *treeFileName = malloc(500); sprintf(treeFileName, "%s",filename); treeFileName = remove_ext(treeFileName, '.', '/'); strcat(treeFileName, ".arv"); FILE* treefile = fopen(treeFileName, "w+"); printf("[ EMISSÃO DA ARVORE ] Iniciando!\n"); pr_exp(treefile, prg, 0); printf("[ EMISSÃO DA ARVORE ] Completada! XD \n"); char *emit = "-llvm-emit"; if(argc == 3 && (strcmp(emit, argv[2]) == 0)){ printf("[ GERACAO DE CODIGO ] Iniciando!\n"); geraCodigoIntermediario(filename, prg); printf("[ GERACAO DE CODGIO ] Completada! (͡° ͜ʖ ͡°)\n"); } } return 0; }
//******************************************************************* // showEvent PRIVATE inherited //******************************************************************* void QBtPackDialog::showEvent( QShowEvent* const in_event ) { QBtShared::resize_width( this, 30 ); QDialog::showEvent( in_event ); { QPalette p = QPalette(); p.setColor( source_->backgroundRole(), palette().color( backgroundRole() ) ); p.setColor( source_->foregroundRole(), palette().color( foregroundRole() ) ); source_->setPalette( p ); } { QPalette p = QPalette(); p.setColor( destination_->backgroundRole(), palette().color( backgroundRole() ) ); p.setColor( destination_->foregroundRole(), palette().color( foregroundRole() ) ); destination_->setPalette( p ); } remove_ext(); display_src( *data_.begin() ); display_dst(); }
static char * build_client_info(const char *name) { char *short_name = remove_ext(name, ".s2"); const char *label = short_name ? short_name : name; char *old_info = getenv("CLIENT_INFO"); int len = strlen(label) + 5 + 5 + 5 + 1; // 5 for "test=", 5 for ";pid=", 5 assuming pid max is "32768" if (old_info) { len += strlen(old_info)+1; // +1 for ';' } char *info = (char*)malloc(len); if (old_info) { snprintf(info, len, "%s;test=%s;pid=%u", old_info, label, getpid()); } else { snprintf(info, len, "test=%s;pid=%u", label, getpid()); } info [len-1] = '\0'; free(short_name); return info; }
admin() { DIR *d; struct dirent *dir; char *file_name, user[100], pass[100], path[100], menu; int ret; login : printf("\n\t\tAdmin Mode\n"); printf("\t\t..........................\n"); printf("\t\tUsername : "******"\t\tPassword : "******"admin123")==0){ listmember : system("cls"); printf("\n\t\tMember List\n"); printf("\t\t..........................\n"); d = opendir("db/pass"); if (d) { while ((dir = readdir(d)) != NULL) { //printf("%s\n", dir->d_name); if ( !strcmp(dir->d_name, ".") || !strcmp(dir->d_name, "..") ){ // do nothing (straight logic) } else { file_name = dir->d_name; // use it printf("\t\tUser: \"%s\"\n",remove_ext(file_name)); } } closedir(d); printf("\t\t..........................\n"); } printf("\t\tTyping Username require to remove : "); gets(user); strcpy(path,"db/pass/"); strcat(path, user); strcat(path, ".db"); ret = remove(path); if(ret == 0) { printf("\t\tDeleted User&Pass successfully\n"); } else { printf("\t\tError: unable to delete the file\n"); } strcpy(path,"db/info/"); strcat(path, user); strcat(path, ".db"); ret = remove(path); if(ret == 0) { printf("\t\tDeleted Info successfully\n"); } else { printf("\t\tError: unable to delete the file\n"); } strcpy(path,"db/app/"); strcat(path, user); strcat(path, "_app1.db"); ret = remove(path); if(ret == 0) { printf("\t\tDeleted Info APP1 successfully\n"); } else { printf("\t\tLog App1 No data...\n"); } strcpy(path,"db/app/"); strcat(path, user); strcat(path, "_app2.db"); ret = remove(path); if(ret == 0) { printf("\t\tDeleted Info APP2 successfully\n"); } else { printf("\t\tLog App2 No data...\n"); } strcpy(path,"db/app/"); strcat(path, user); strcat(path, "_app3.db"); ret = remove(path); if(ret == 0) { printf("\t\tDeleted Info APP3 successfully\n"); } else { printf("\t\tLog App3 No data...\n"); } printf("\t\t..........................\n"); printf("\t\tShow Member List Enter : 1\n"); printf("\t\tExit Enter : 0\n"); menu = getch(); if(menu == '1'){ fflush(stdin); goto listmember; } }else{ printf("\n\t\t\tCan't login try again \n"); printf("\n\t\t***************************************\n\n"); fflush(stdin); goto login; } }
void analyse_param_ce( int argc, char *argv[], int* m, int* K, char *input, char* input_file_Q, char* input_file_F, char *input_file_I) { int i; int g_data = -1; char *tmp_file; char tmp[512]; int g_m = 0; for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { switch (argv[i][1]) { // the number of ancestral populations case 'K': i++; if (argc == i || argv[i][0] == '-') print_error_ce("cmd","K (number of ancestral populations)"); *K = atoi(argv[i]); strcpy(tmp,argv[i]); break; // the ploidy case 'm': i++; if (argc == i || argv[i][0] == '-') print_error_ce("cmd","m (number of alleles)"); *m = atoi(argv[i]); g_m = 1; break; // help case 'h': print_help_ce(); exit(1); break; // licence case 'l': print_licence_snmf(); exit(1); break; // genotypic file case 'x': i++; if (argc == i || argv[i][0] == '-') print_error_ce("cmd","x (genotype file)"); g_data = 0; strcpy(input,argv[i]); break; // individual admixture file case 'q': i++; if (argc == i || argv[i][0] == '-') print_error_ce("cmd","q (individual admixture coefficients file)"); strcpy(input_file_Q,argv[i]); break; // ancestral genotype frequency file case 'g': i++; if (argc == i || argv[i][0] == '-') print_error_ce("cmd","g (ancestral genotype frequencies file)"); strcpy(input_file_F,argv[i]); break; // genotypic file with masked data case 'i': i++; if (argc == i || argv[i][0] == '-') print_error_ce("cmd","i (genotype file with masked genotypes)"); strcpy(input_file_I,argv[i]); break; default: print_error_ce("basic",NULL); } } else { print_error_ce("basic",NULL); } } // no genotypic file if (g_data == -1) print_error_ce("option","-x genotype_file"); // ploidy and negative if (g_m && *m <= 0) print_error_ce("missing", NULL); // negative K if (*K <= 0) print_error_ce("missing",NULL); // write output file names tmp_file = remove_ext(input,'.','/'); if (!strcmp(input_file_F,"")) { strcpy(input_file_F,tmp_file); strcat(input_file_F,"_I."); strcat(input_file_F,tmp); strcat(input_file_F,".G"); } if (!strcmp(input_file_Q,"")) { strcpy(input_file_Q,tmp_file); strcat(input_file_Q,"_I."); strcat(input_file_Q,tmp); strcat(input_file_Q,".Q"); } if (!strcmp(input_file_I,"")) { strcpy(input_file_I,tmp_file); strcat(input_file_I,"_I.geno"); } free(tmp_file); }
void analyse_param_snmf(int argc, char *argv[], sNMF_param param) { int i; int g_data = -1; char *tmp_file; char tmp[512]; int g_c = 0; int g_m = 0; for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { switch (argv[i][1]) { case 'K': i++; if (argc == i || argv[i][0] == '-') print_error_nmf("cmd","K (number of clusters)",0); param->K = atoi(argv[i]); strcpy(tmp,argv[i]); break; case 's': i++; if (argc == i || argv[i][0] == '-') print_error_nmf("cmd","s (seed number)",0); param->seed= atoll(argv[i]); break; case 'm': i++; if (argc == i || argv[i][0] == '-') print_error_nmf("cmd","m (number of alleles)",0); param->m = atoi(argv[i]); g_m = 1; break; case 'a': i++; if (argc == i || argv[i][0] == '-') print_error_nmf("cmd","alpha (regularization parameter)",0); param->alpha = (double) atof(argv[i]); if (param->alpha < 0) { param->alpha = 0; } break; case 'h': // global print_help_snmf(); exit(1); break; case 'l': // global print_licence_snmf(); exit(1); break; case 'e': i++; if (argc == i || argv[i][0] == '-') print_error_nmf("cmd","e (tolerance error in the algorithm)",0); param->tolerance = (double) atof(argv[i]); if (param->tolerance < 0) { param->tolerance = 0; } break; case 'c': i++; if (argc == i || argv[i][0] == '-') { param->pourcentage = 0.05; i--; } else { param->pourcentage = (double) atof(argv[i]); } g_c = 1; break; case 'i': i++; if (argc == i || argv[i][0] == '-') print_error_nmf("cmd","i (number of iterations)",0); param->maxiter = atoi(argv[i]); break; case 'I': i++; if (argc == i || argv[i][0] == '-') { param->I = -1; i--; } else param->I = (int) atoi(argv[i]); break; case 'x': i++; if (argc == i || argv[i][0] == '-') print_error_nmf("cmd","x (genotype file)",0); g_data = 0; strcpy(param->input_file,argv[i]); break; case 'q': i++; if (argc == i || argv[i][0] == '-') print_error_nmf("cmd","q (individual admixture coefficients file)",0); strcpy(param->output_file_Q,argv[i]); break; case 'Q': i++; if (argc == i || argv[i][0] == '-') print_error_nmf("cmd","Q (admixture coefficients initialization file)",0); strcpy(param->input_file_Q,argv[i]); break; case 'g': i++; if (argc == i || argv[i][0] == '-') print_error_nmf("cmd","g (ancestral genotype frequencies file)",0); strcpy(param->output_file_F,argv[i]); break; case 'p': i++; if (argc == i || argv[i][0] == '-') print_error_nmf("cmd","p (number of processes)",0); param->num_thrd = atoi(argv[i]); break; default: print_error_nmf("basic",NULL,0); } } else { print_error_nmf("basic",NULL,0); } } if (g_data == -1) print_error_nmf("option","-x genotype_file",0); if (param->K <= 0) print_error_nmf("missing",NULL,0); if (param->num_thrd <= 0) print_error_nmf("missing",NULL,0); if (g_m && param->m <= 0) print_error_nmf("missing",NULL,0); if (param->maxiter <= 0) print_error_nmf("missing",NULL,0); if (g_c && (param->pourcentage <= 0 || param->pourcentage >= 1)) print_error_nmf("missing",NULL,0); // write output file name tmp_file = remove_ext(param->input_file,'.','/'); if (!strcmp(param->output_file_Q,"")) { strcpy(param->output_file_Q,tmp_file); strcat(param->output_file_Q,"."); strcat(param->output_file_Q,tmp); strcat(param->output_file_Q,".Q"); } if (!strcmp(param->output_file_F,"")) { strcpy(param->output_file_F,tmp_file); strcat(param->output_file_F,"."); strcat(param->output_file_F,tmp); strcat(param->output_file_F,".G"); } free(tmp_file); }
int handle_file(const char *file, struct config_opts_t *config_opts) { const char *dest_dir = config_opts->dest_dir; const char *file_name = basename(strdup(file)); char dest_file[1024] = ""; char lz4pack[1024] = ""; if (check_lzo_header(file)) { constructPath(dest_file, dest_dir, file_name, ".lzounpack"); printf("Extracting LZO file to: %s\n", dest_file); if (lzo_unpack(file, dest_file) == 0) { handle_file(dest_file, config_opts); return EXIT_SUCCESS; } } else if (is_nfsb(file)) { constructPath(dest_file, dest_dir, file_name, ".unnfsb"); printf("Extracting nfsb image to: %s.\n\n", dest_file); unnfsb(file, dest_file); handle_file(dest_file, config_opts); return EXIT_SUCCESS; } else if (is_lz4(file)) { constructPath(dest_file, dest_dir, file_name, ".unlz4"); printf("UnLZ4 file to: %s\n", dest_file); decode_file(file, dest_file); return EXIT_SUCCESS; } else if (is_squashfs(file)) { constructPath(dest_file, dest_dir, file_name, ".unsquashfs"); printf("Unsquashfs file to: %s\n", dest_file); rmrf(dest_file); unsquashfs(file, dest_file); return EXIT_SUCCESS; } else if (is_gzip(file)) { constructPath(dest_file, dest_dir, "", ""); printf("Extracting gzip file %s\n", file_name); strcpy(dest_file, file_uncompress_origname((char *)file, dest_file)); return EXIT_SUCCESS; } else if(is_cramfs_image(file, "be")) { constructPath(dest_file, dest_dir, file_name, ".cramswap"); printf("Swapping cramfs endian for file %s\n",file); cramswap(file, dest_file); return EXIT_SUCCESS; } else if(is_cramfs_image(file, "le")) { constructPath(dest_file, dest_dir, file_name, ".uncramfs"); printf("Uncramfs %s to folder %s\n", file, dest_file); rmrf(dest_file); uncramfs(dest_file, file); return EXIT_SUCCESS; } else if (isFileEPK2(file)) { extractEPK2file(file, config_opts); return EXIT_SUCCESS; } else if (isFileEPK1(file)) { extract_epk1_file(file, config_opts); return EXIT_SUCCESS; } else if (is_kernel(file)) { constructPath(dest_file, dest_dir, file_name, ".unpaked"); printf("Extracting boot image to: %s.\n\n", dest_file); extract_kernel(file, dest_file); handle_file(dest_file, config_opts); return EXIT_SUCCESS; } else if(isPartPakfile(file)) { constructPath(dest_file, dest_dir, remove_ext(file_name), ".txt"); printf("Saving Partition info to: %s\n", dest_file); dump_partinfo(file, dest_file); return EXIT_SUCCESS; } else if(is_jffs2(file)) { constructPath(dest_file, dest_dir, file_name, ".unjffs2"); printf("jffs2extract %s to folder %s\n", file, dest_file); rmrf(dest_file); jffs2extract(file, dest_file, "1234"); return EXIT_SUCCESS; } else if(isSTRfile(file)) { constructPath(dest_file, dest_dir, file_name, ".ts"); setKey(); printf("\nConverting %s file to TS: %s\n", file, dest_file); convertSTR2TS(file, dest_file, 0); return EXIT_SUCCESS; } else if(!memcmp(&file[strlen(file)-3], "PIF", 3)) { constructPath(dest_file, dest_dir, file_name, ".ts"); setKey(); printf("\nProcessing PIF file: %s\n", file); processPIF(file, dest_file); return EXIT_SUCCESS; } else if(symfile_load(file) == 0) { constructPath(dest_file, dest_dir, file_name, ".idc"); printf("Converting SYM file to IDC script: %s\n", dest_file); symfile_write_idc(dest_file); return EXIT_SUCCESS; } return EXIT_FAILURE; }
int main(int argc,char *argv[]) { char infilename[13]; char a,channel=0,pan_r,pan_l,ext=OFF; char f_channel=OFF;/* トラックデータ先アドレス登録テーブルがあるか */ char pc_mode=0;/* パーカッションモード */ static char ch[7]={0,OFF,OFF,OFF,OFF,OFF,OFF}; static int ch_length[7]={4,4,4,4,4,4,4}; static int amari[7]={0,0,0,0,0,0,0}; int i,j,k,line=0,length=0,put_length,tone; double futen; FILE *infile,*outfile; if( argc != 2 ){ puts(short_help); puts("\tUsagi:MML [mml-file]\n"); exit(1); } for(i=0; argv[1][i]!=0 ;i++){ if(argv[1][i]=='.'){ ext=ON; break; } } strcpy(infilename,argv[1]); if(ext==OFF){ strcat(infilename,".MML"); } if( (infile=fopen(infilename,"r")) == NULL ){ printf("File not found:[%s]\n",infilename); exit(1); } printf("INFILE:%s\n",infilename); strcpy(buf,remove_ext(infilename)); strcat(buf,".asm"); if( (outfile=fopen(buf,"w")) == NULL ){ printf("\nCan't open OUTPUT_FILE.\n"); exit(1); } /* 出力開始 */ fputs("\torg\t\t$8000\n", outfile); /* トラックデータインデックステーブル */ fputs("\ track_index:\n\ \tdw\t\ttrack0\n\ ;\n", outfile); /* ループ開始 */ while((i=fgetc(infile)) != EOF){ line++; switch((char)i){ case '.': /* 指令である */ fgetstr(buf,infile,"="); if( /*strnicmp*/strncasecmp(buf, "START", 5) == 0 ){ channel=buf[5]-'0'; if( channel<1 || channel>6 ){ printf("Channel Error in %s:%d\n",infilename,line); exit(1); } if( ch[channel] == ON ){ printf("Channel [%d] already exist in %s:%d",channel,infilename,line); exit(1); } ch[channel]=ON; f_channel=ON; ch_length[channel]=4; pc_mode=0; fputs("START_CH", outfile); fputc(buf[5], outfile); fputs(":\n" ,outfile); goto MML_EXT; } break; case ' ': case '\t': /* 前の続き */ goto MML_EXT; case ';': /* コメントである */ fgetstr(buf, infile, "\n\r"); case '\n': case '\r': break; default: /* それ以外は文字列 */ ungetc((char)i, infile); channel=0; ch_length[channel]=4; pc_mode=0; fgetstr(buf2, infile, "="); strcpy(buf,"LABEL_"); strcat(buf,buf2); strcat(buf,":\n"); fputs( buf, outfile); MML_EXT: j=0; fgetstr(buf,infile,";\n\r"); /* MML展開ループ */ while(buf[j] != 0){ /* 通常の音符 */ if( (k=instr("C D EF G A B", buf[j])) != 0 && pc_mode==0 ){ j++; if(buf[j]=='#' || buf[j]=='+'){ k++; /* 半音上げる */ j++; }else if(buf[j]=='-'){ k--; /* 半音下げる */ j++; } /* 音長 */ length=0; while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } switch(length){ case 0: length=ch_length[channel]; break; case 1: case 2: case 3: case 4: case 6: case 8: case 12: case 16: case 24: case 32: case 48: case 64: case 96: break; default: printf("Length error in:%d(%d)\n",line,length); exit(1); } /* kが1〜12以外のときの前処理 */ if(k==0){ fputs("\tdb\t\t$d9 \t;オクターブダウン\n", outfile); }else if(k==13){ fputs("\tdb\t\t$d8 \t;オクターブアップ\n", outfile); } tone=k; if(k==0)tone=12; if(k==13)tone=1; tone*=16; /* ダイレクトレングスモード */ put_length=(int)( (192+amari[channel])/length); amari[channel]=(int)( (192+amari[channel])%length); /* 符点処理 */ futen=1.0; length=1; while(buf[j]=='.'){ futen += pow(0.5, length++); j++; } put_length*=futen; fprintf(outfile, "\tdb\t\t$%02x,$%02x\t;オンプ\n", tone, put_length); /* kが1〜12以外のときの後処理 */ if(k==0){ fputs("\tdb\t\t$d8 \t;オクターブアップ\n", outfile); }else if(k==13){ fputs("\tdb\t\t$d9 \t;オクターブダウン\n", outfile); } /* 音長終わり */ /* 休符 */ }else if( buf[j]=='R' && pc_mode==0 ){ j++; /* 休符長 */ length=0; while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } switch(length){ case 0: length=4; break; case 1: case 2: case 3: case 4: case 6: case 8: case 12: case 16: case 24: case 32: case 48: case 64: case 96: break; default: printf("Length error in:%d(%d)\n",line,length); exit(1); } put_length=(192/length); /* 符点処理 */ futen=1.0; length=1; while(buf[j]=='.'){ futen += pow(0.5, length++); j++; } put_length*=futen; fprintf(outfile, "\tdb\t\t$00,$%02x\t;キュウフ\n",put_length); /* オクターブ */ }else if(buf[j] == 'O'){ j++; /* オクターブ高 */ length=0; while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } if(length<1 || 7<length){ printf("Parameter error of 'O' in:%d (%d)\n",line,length); exit(1); } fprintf(outfile, "\tdb\t\t$%02x \t;オクターブ\n",0xD0+length); /* オクターブup */ }else if(buf[j] == '>'){ j++; fputs("\tdb\t\t$d8 \t;オクターブアップ\n", outfile); /* オクターブdown */ }else if(buf[j] == '<'){ j++; fputs("\tdb\t\t$d9 \t;オクターブダウン\n", outfile); /* タイ */ }else if(buf[j] == '&'){ j++; fputs("\tdb\t\t$da \t;タイ\n", outfile); /* テンポ */ }else if(buf[j] == 'T'){ j++; length=0; while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } if( length<35 || 255<length ){ printf("Parameter error of 'T' in:%d (%d)\n",line,length); exit(1); } fprintf(outfile, "\tdb\t\t$db,$%02x\t;テンポ\n",length); /* ヴォリューム0〜31 */ }else if(buf[j] == 'V'){ j++; length=0; while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } if( length<0 || 31<length ){ printf("Parameter error of 'V' in:%d (%d)\n",line,length); exit(1); } fprintf(outfile, "\tdb\t\t$dc,$%02x\t;ボリューム\n",(char)length); /* パンポット0x00〜0xFF */ }else if(buf[j] == 'P'){ j++; pan_r=0; pan_l=0; while( isdigit((int)buf[j]) ){ pan_r = pan_r*10+buf[j]-'0'; j++; } if(buf[j]!=','){ printf("Parameter error of 'P' in:%d (%d)\n",line,length); exit(1); } j++; while( isdigit((int)buf[j]) ){ pan_l = pan_l*10+buf[j]-'0'; j++; } if( (pan_r<0 || 15<pan_r)||(pan_l<0 || 15<pan_l) ){ printf("Parameter error of 'P' in:%d (%d)\n",line,length); exit(1); } fprintf(outfile, "\tdb\t\t$dd,$%1x%1x\t;パンポット\n",pan_r,pan_l); /* 音長比1〜8 */ }else if(buf[j] == 'Q'){ j++; length=0; while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } if( length<1 || 8<length ){ printf("Parameter error of 'Q' in:%d (%d)\n",line,length); exit(1); } fprintf(outfile, "\tdb\t\t$de,$%02x\t;オンチョウヒ\n",(char)length); /* 相対ヴォリューム */ /* ダルセーニョ */ /* セーニョ */ /* リピートビギン */ }else if(buf[j] == '['){ j++; length=0; while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } if( length<0 || 255<length ){ printf("Parameter error of '[' in:%d (%d)\n",line,length); exit(1); } fprintf(outfile, "\tdb\t\t$e3,$%02x\t;リピートビギン\n",(char)length); /* リピートエンド */ }else if(buf[j] == ']'){ j++; fputs("\tdb\t\t$e4 \t;リピートエンド\n", outfile); /* ウェーブ(音色) */ }else if( (buf[j] == '@') && isdigit(buf[j+1]) ){ j++; length=0; if( !isdigit((int)buf[j]) ){ printf("Parameter error of '@' in:%d (null)\n",line); exit(1); } while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } if( length<0 || 44<length ){ printf("Parameter error of '@' in:%d (%d)\n",line,length); exit(1); } fprintf(outfile, "\tdb\t\t$e5,$%02x\t;オンショク\n",(char)length); /* エンベロープ */ }else if( (buf[j] == '@') && (buf[j+1] == 'E') ){ j++; j++; length=0; while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } if( length<0 || 127<length ){ printf("Parameter error of '@E' in:%d (%d)\n",line,length); exit(1); } fprintf(outfile, "\tdb\t\t$e6,$%02x\t;エンベロープ\n",(char)length); /* 周波数変調 */ /* FMディレイ */ /* FM補正 */ /* ピッチエンベロープ(PE) */ /* PEディレイ */ /* デチューン */ }else if( (buf[j] == '@') && (buf[j+1] == 'D') ){ j++; j++; length=0; put_length=1; if(buf[j]=='-'){ /* マイナスの値 */ put_length=-1; j++; } while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } if( length<0 || 128<length ){ printf("Parameter error of '@D' in:%d (%d)\n",line,length); exit(1); } put_length*=length; fprintf(outfile, "\tdb\t\t$ec,$%02x\t;デチューン\n",(char)put_length); /* スイープ */ /* スイープタイム */ /* ジャンプ */ }else if(buf[j] == '/'){ j++; k=6; strcpy(buf2, "LABEL_"); while( buf[j] != '/' ){ buf2[k]=buf[j]; j++; k++; } j++; buf2[k]='\0'; if( k==6 ){ printf("Label name error in:%d\n",line); exit(1); } fprintf(outfile, "\tdb\t\t$ef \t;ジャンプ\n"); fprintf(outfile, "\tdw\t\t%s\t;ジャンプ\n",buf2); /* コール */ }else if(buf[j] == '('){ j++; k=6; strcpy(buf2, "LABEL_"); while( buf[j] != ')' ){ buf2[k]=buf[j]; j++; k++; } j++; buf2[k]='\0'; if( k==6 ){ printf("Label name error in:%d\n",line); exit(1); } fprintf(outfile, "\tdb\t\t$f0 \t;コール\n"); fprintf(outfile, "\tdw\t\t%s\t;コール\n",buf2); /* リターン */ }else if(buf[j] == '\''){ j++; fputs("\tdb\t\t$f1 \t;リターン\n", outfile); /* 移調 */ /* 相対移調 */ /* 全体移調 */ /* ヴォリュームチェンジ */ /* パンライトチェンジ */ /* パンレフトチェンジ */ /* モード */ }else if( (buf[j] == '@') && (buf[j+1] == 'M') ){ j++; j++; length=0; while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } if( length<0 || 2<length ){ printf("Parameter error of '@M' in:%d (%d)\n",line,length); exit(1); } pc_mode=length; fprintf(outfile, "\tdb\t\t$f8,$%02x\t;モード\n",(char)length); /* フェードアウト */ /* データエンド */ }else if(buf[j] == '*'){ j++; fputs("\tdb\t\t$ff \t;データエンド\n", outfile); /* ここからは独自のコマンド */ /* Lコマンド */ }else if(buf[j] == 'L'){ j++; length=0; while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } switch(length){ case 1: case 2: case 3: case 4: case 6: case 8: case 12: case 16: case 24: case 32: case 48: case 64: case 96: break; default: printf("Parameter error of 'L' in:%d (%d)\n",line,length); exit(1); } ch_length[channel]=length; /* 拡張ヴォリューム @V0〜128 */ }else if( (buf[j] == '@') && (buf[j+1] == 'V') ){ j++; j++; length=0; while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } if( length<0 || 127<length ){ printf("Parameter error of '@V' in:%d (%d)\n",line,length); exit(1); } put_length=length*31/127; fprintf(outfile, "\tdb\t\t$dc,$%02x\t;ボリューム(@V)\n",(char)put_length); /* パーカッションモードの音符 */ }else if( (k=instr("RBSMCH ", buf[j])) != 0 && pc_mode==1 ){ j++; while( !isdigit(buf[j]) ){ j++; } if(buf[j]=='!' ){ /* ヴォリューム強調 */ j++; } /* 音長 */ length=0; while( isdigit((int)buf[j]) ){ length = length*10+buf[j]-'0'; j++; } switch(length){ case 0: length=ch_length[channel]; break; case 1: case 2: case 3: case 4: case 6: case 8: case 12: case 16: case 24: case 32: case 48: case 64: case 96: break; default: printf("Length error in:%d(%d)\n",line,length); exit(1); } tone=k; if(k==0)tone=12; if(k==13)tone=1; tone*=16; /* ダイレクトレングスモード */ put_length=(int)( (192+amari[channel])/length); amari[channel]=(int)( (192+amari[channel])%length); /* 符点処理 */ futen=1.0; length=1; while(buf[j]=='.'){ futen += pow(0.5, length++); j++; } put_length*=futen; fprintf(outfile, "\tdb\t\t$%02x,$%02x\t;オンプ(パーカッション)\n", tone, put_length); /* 音長終わり */ /* エラー */ }else{ printf("Not Support [%c]in:%d\n",buf[j],line); exit(1); } }/* MML展開ループ終わり */ break; }/* switch(char)i)の終わり */ }/* 読み込みがEOF */ fclose(infile); /* トラックデータ先アドレス登録テーブル */ if(f_channel==OFF){ puts("No channel data.\n"); exit(1); } fputs("track0:\n", outfile); for(a=0, i=1; i<=6; i++){ a<<=1; a+=ch[i]; } fprintf(outfile, "\tdb\t\t$%02x\t;00%1d%1d_%1d%1d%1d%1db\n",a,ch[1],ch[2],ch[3],ch[4],ch[5],ch[6]); for(i=1; i<=6; i++) if(ch[i]==ON) fprintf(outfile, "\tdw\t\tSTART_CH%1d\n",i); #ifndef osx /* damn BSD */ fcloseall(); #endif return 0; }