OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable/] [mp3/] [sw/] [utils/] [bin2flimg.c] - Diff between revs 392 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 392 Rev 1765
#include <stdio.h>
#include <stdio.h>
 
 
int main(int argc, char **argv)
int main(int argc, char **argv)
{
{
 
 
        FILE  *fd;
        FILE  *fd;
        int c, i, j, width;
        int c, i, j, width;
        unsigned long word;
        unsigned long word;
 
 
        if(argc < 3) {
        if(argc < 3) {
                printf("no input file specified");
                printf("no input file specified");
                exit(1);
                exit(1);
        }
        }
 
 
        width = atoi(argv[1]);
        width = atoi(argv[1]);
 
 
        fd = fopen( argv[2], "r" );
        fd = fopen( argv[2], "r" );
 
 
        while (!feof(fd)) {
        while (!feof(fd)) {
                j = 0;
                j = 0;
                word = 0;
                word = 0;
                while (j < width) {
                while (j < width) {
                        c = fgetc(fd);
                        c = fgetc(fd);
                        if (c == EOF) {
                        if (c == EOF) {
                                c = 0;
                                c = 0;
                        }
                        }
                        word = (word << 8) + c;
                        word = (word << 8) + c;
                        j++;
                        j++;
                }
                }
                if(width == 1)
                if(width == 1)
                        printf("%.2lx\n", word);
                        printf("%.2lx\n", word);
                else if(width == 2)
                else if(width == 2)
                        printf("%.4lx\n", word);
                        printf("%.4lx\n", word);
                else
                else
                        printf("%.8lx\n", word);
                        printf("%.8lx\n", word);
        }
        }
        return 0;
        return 0;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.