/[pcsx2_0.9.7]/branch/debug/0.X/0.9.X/0.9.7/r3113/fps2bios/romdir.c
ViewVC logotype

Annotation of /branch/debug/0.X/0.9.X/0.9.7/r3113/fps2bios/romdir.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (hide annotations) (download)
Tue Sep 7 03:29:01 2010 UTC (10 years, 7 months ago) by william
Original Path: branch/r3113_0.9.7_beta/fps2bios/romdir.c
File MIME type: text/plain
File size: 1798 byte(s)
branching from upstream revision (http://pcsx2.googlecode.com/svn/trunk
): r3113 to
https://svn.netsolutions.dnsalias.com/websvn/ps2/pcsx2/pcsx2_0.9.7/branch/r3113_0.9.7_beta
1 william 31 /***************************************************************
2     * romdir.c, based over Alex Lau (http://alexlau.8k.com) RomDir *
3     ****************************************************************/
4     #include <stdio.h>
5     #include <string.h>
6     #include <ctype.h>
7     #include <sys/types.h>
8     #include <sys/stat.h>
9    
10     #define MAXFILES 200
11     #define DIRENTRY_SIZE 16
12     #define BUFFSIZE 16384
13    
14     struct __attribute__ ((__packed__)) romdir {
15     /*following variable must place in designed order*/
16     char fileName[10];
17     unsigned short extInfoSize;
18     unsigned long fileSize;
19     } rd;
20    
21     int main(int argc, char *argv[]) {
22     struct stat buf;
23     FILE *romdir;
24     FILE *extinfo;
25     int i, j;
26    
27     printf("fps2bios romdir generator\n");
28     if (argc < 2){
29     printf("usage: %s infile1 [infile2...]\n", argv[0]);
30     return 1;
31     }
32    
33     romdir = fopen("ROMDIR", "wb");
34     if (romdir == NULL) {
35     printf("failed to create ROMDIR\n");
36     return 1;
37     }
38    
39     extinfo = fopen("EXTINFO", "wb");
40     if (extinfo == NULL) {
41     printf("failed to create EXTINFO\n");
42     return 1;
43     }
44    
45     for (i=1; i<argc; i++) {
46     memset(&rd, 0, sizeof(rd));
47     if (strcmp(argv[i], "ROMDIR") == 0) {
48     strncpy(rd.fileName, argv[i], 9);
49     rd.extInfoSize = 0;
50     rd.fileSize = (argc-1)*16+16;
51     fwrite(&rd, 1, 16, romdir);
52     continue;
53     }
54     if (stat(argv[i], &buf) == -1) {
55     printf("warning: %s file is missing\n", argv[i]);
56     continue;
57     }
58     for (j=0; j<9; j++) {
59     if (argv[i][j] == ',' || argv[i][j] == 0) break;
60     rd.fileName[j] = argv[i][j];
61     }
62     memset(rd.fileName+j, 0, 10-j);
63     rd.fileSize = buf.st_size;
64    
65     if (argv[i][j] == ',') {
66     // for (j=0; j<256; j++) {
67     // }
68     // rd.extInfoSize+= j;
69     } else { // no extInfo
70     rd.extInfoSize = 0;
71     }
72    
73     fwrite(&rd, 1, 16, romdir);
74     }
75     memset(&rd, 0, sizeof(rd));
76     fwrite(&rd, 1, 16, romdir);
77    
78     fclose(romdir);
79     fclose(extinfo);
80    
81     return 0;
82     }

  ViewVC Help
Powered by ViewVC 1.1.22