URL
https://opencores.org/ocsvn/s6soc/s6soc/trunk
Subversion Repositories s6soc
[/] [s6soc/] [trunk/] [sw/] [host/] [buildsamples.cpp] - Rev 22
Go to most recent revision | Compare with Previous | Blame | View Log
//////////////////////////////////////////////////////////////////////////////// // // Filename: buildsamples.cpp // // Project: CMod S6 System on a Chip, ZipCPU demonstration project // // Purpose: // // Creator: Dan Gisselquist, Ph.D. // Gisselquist Technology, LLC // //////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2015-2016, Gisselquist Technology, LLC // // This program is free software (firmware): 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 3 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 MERCHANTIBILITY 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. (It's in the $(ROOT)/doc directory, run make with no // target there if the PDF file isn't present.) If not, see // <http://www.gnu.org/licenses/> for a copy. // // License: GPL, v3, as defined and found on www.gnu.org, // http://www.gnu.org/licenses/gpl.html // // //////////////////////////////////////////////////////////////////////////////// // // #include <stdio.h> #include <stdlib.h> #include <string.h> #define SLEN 512 #define ILEN (SLEN/2) int main(int argc, char **argv) { FILE *fp, *legal; char cbuf[SLEN]; short sbuf[SLEN]; int nread = 0, nr; fp = fopen(argv[1], "rb"); if (!fp) { fprintf(stderr, "Could not open %s for reading\n", argv[1]); exit(EXIT_FAILURE); } /* legal = fopen("../legal.txt", "r"); if (!legal) legal = fopen("../../legal.txt", "r"); */ legal = NULL; if (legal) { while(fgets(cbuf, SLEN, legal)) { if (strncmp(cbuf, "// Filename:", 12)==0) printf("// Filename:\tsamples.c\n"); else printf("%s", cbuf); } fclose(legal); } else { printf("// This file should be copyrighted but I can't find\n"); printf("// the copyright statement.\n//\n"); } printf( "// This file is computer generated--DO NOT EDIT IT! The generator file can\n" "// be found in trunk/sw/host/%s\n" "//\n" "//\n" "#ifndef\tSOUND_DATA_H\n" "#define\tSOUND_DATA_H\n\n" "const\tint\tsound_data[] = {\n", __FILE__); while((nr = fread(sbuf, sizeof(short), SLEN, fp))>0) { int pos = 0; nread += nr; while(pos < nr) { printf("\t"); for(int i=0; (pos<((nr+1)&-2))&&(i<8); i+=2) { int iv = (sbuf[pos]<<16)|(sbuf[pos+1] & 0x0ffff); printf("0x%08x, ", iv); pos+=2; } printf("\n"); } } printf("\t0\n};\n"); printf("\n\n" "#define\tNSAMPLES\t%d\n" "#define\tNSAMPLE_WORDS\t%d\n" "\n\n#endif\n", nread, 1+((nread+1)>>1)); }
Go to most recent revision | Compare with Previous | Blame | View Log