⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mnu2txt.c

📁 VS1000B的应用文档,很好启发.大家可以
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include <ctype.h>//#define OLD_FORMATtypedef unsigned char ubyte;struct ENTRY {    ubyte parent[2];        /*0 parent index:  0 or 1..65535 */    ubyte subtree[2];       /*1 subtree index: 0 or 1..65535 */    ubyte extra;            /*2 number of extra files to play */    ubyte flags;            /*2 flags for this entry */#ifdef OLD_FORMAT    ubyte name[42];         /*3 entry name (for display) */#else    ubyte fileName[8];      /*28 FAT short filename, .ogg implied */#endif    ubyte startFraction[2]; /*24 clip start position, x/65536 seconds */    ubyte startSeconds[2];  /*25 clip start position, seconds */    ubyte endFraction[2];   /*26 clip end position, x/65536 seconds */    ubyte endSeconds[2];    /*27 clip end position, seconds */#ifdef OLD_FORMAT    ubyte fileName[8];      /*28 FAT short filename, .ogg implied */#else    ubyte name[42];         /*3 entry name (for display) */#endif};#define MFLG_LAST  1 /* last entry */#define MFLG_FIRST 2 /* first entry */#define MFLG_USEENDTIME 4 /* play only to the specified end time */#define MFLG_ENDPLAY 8 /* end of leaf entries, stop playing */struct MenuTemp;struct MenuTemp {    char menuName[80];    //ubyte parent[2];        /*(0 parent index:  0 or 1..65535) */    //ubyte subtree[2];       /*1 subtree index: 0 or 1..65535 */    char subMenu[80];    int subTree;    int parent;    ubyte extra;            /*2 number of extra files to play */    ubyte flags;            /*2 flags for this entry */    ubyte name[80];         /*3 entry name (for display) */    double startTime;    double endTime;    ubyte fileName[80];      /*28 FAT short filename, .ogg implied */};struct MenuTemp menuTemp[65536] = {0};int menuTempNum = 0;int main(int argc, char *argv[]) {    FILE *fp = fopen((argc > 1) ? argv[1] : "menu.mnu", "rb");    long sz, l;    struct ENTRY *e, *c;    int cnt;    if (!fp) {	fprintf(stderr, "Could not open menu.mnu for reading\n");	exit(10);    }    fseek(fp, 0, SEEK_END);    sz = ftell(fp);    fseek(fp, 0, SEEK_SET);    if ((e = malloc(sz))) {	fread(e, 1, sz, fp);    } else {	fprintf(stderr, "allocation of %ld failed\n", sz);    }    fclose(fp);    /* fix parent references if they are not present */    c = e;    cnt = 0;    for (l=0;l<sz;l+=sizeof(struct ENTRY)) {	int sub = (c->subtree[0]<<8) | c->subtree[1];	if (sub) {	    struct ENTRY *m = &e[sub];	    while ((char *)m < (char *)e+sz) {		m->parent[0] = cnt>>8;		m->parent[1] = cnt&255;		if ((m->flags & MFLG_LAST))		    break;		m++;	    }	}	cnt++;	c++;    }    c = e;    for (l=0;l<sz;l+=sizeof(struct ENTRY)) {	if (c->flags & MFLG_FIRST) {	    if (l==0) {		printf("--main menu--\n");	    } else {		int parent = (c->parent[0]<<8) | c->parent[1];		struct ENTRY *m = &e[parent];		printf("--%s--\n", m->name);	    }	}	{	    int sub = (c->subtree[0]<<8) | c->subtree[1];	    long t;	    int times = 1;	    char fileName[9];	    strncpy(fileName, c->fileName, 8);	    fileName[8] = 0;	    printf("\"%s\"", c->name);	    if (fileName[0] == ':') {		printf(" bookmark %d", (c->fileName[2]<<8) | c->fileName[3]);		times = 0;	    } else if (c->fileName[0] == '!') {		printf(" timer %d", (c->fileName[2]<<8) | c->fileName[3]);		times = 0;	    } else {		if (sub) {		    if (c->flags & MFLG_USEENDTIME) {			printf(" entry \"%s\"", e[sub].name);		    } else {			printf(" submenu \"%s\"", c->name);			times = 0;		    }		    if (c->fileName[0])			printf(" autoplay");		} else if (c->fileName[0]) {		    printf(" file \"%s\"", fileName);		}	    }	    if (times) {		t = (c->startFraction[0]<<8) | c->startFraction[1];		t |= ((c->startSeconds[0]<<8) | c->startSeconds[1])<<16;//printf(" %d %d", c->startSeconds[0], c->startSeconds[1]);		printf(" %8.3f", t / 65536.0);		t = (c->endFraction[0]<<8) | c->endFraction[1];		t |= ((c->endSeconds[0]<<8) | c->endSeconds[1])<<16;		if (t == 0x7fffffff) {		    printf(" end");		} else {		    printf(" %8.3f", t / 65536.0);		}		if ((c->flags & MFLG_USEENDTIME) && sub == 0) {		    printf(" useend");		}	    }	    printf("\n");	}	c++;    }    printf("--end--\n");    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -