/[pcsx2_0.9.7]/branch/r3113_0.9.7_beta/fps2bios/kernel/iopload/romdir.c
ViewVC logotype

Contents of /branch/r3113_0.9.7_beta/fps2bios/kernel/iopload/romdir.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (show annotations) (download)
Tue Sep 7 03:29:01 2010 UTC (10 years, 10 months ago) by william
File MIME type: text/plain
File size: 3112 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 /***************************************************************
2 * romdir.c, based over Alex Lau (http://alexlau.8k.com) RomDir *
3 ****************************************************************/
4 #include "romdir.h"
5
6 // searches between beginning and end addresses for a romdir structure.
7 // if found it returns info about it in romDirInfo.
8 //
9 // args: address to start searching from
10 // address to stop searching at
11 // gets filled in with info if found
12 // returns: a pointer to the filled in romDirInfo if successful
13 // NULL if error
14 ROMDIR_INFO* searchRomDir(const u32* searchStartAddr, const u32* searchEndAddr, ROMDIR_INFO* romDirInfo)
15 {
16 int offset = 0;
17 ROMDIR_ENTRY* dir_entry = (ROMDIR_ENTRY*)searchStartAddr;
18 while (dir_entry < (ROMDIR_ENTRY*)searchEndAddr)
19 {
20 if(dir_entry->name[0] == 'R' &&
21 dir_entry->name[1] == 'E' &&
22 dir_entry->name[2] == 'S' &&
23 dir_entry->name[3] == 'E' &&
24 dir_entry->name[4] == 'T' &&
25 dir_entry->name[5] == 0 &&
26 (ROUND_UP(dir_entry->fileSize,16) == offset) )
27 {
28 romDirInfo->romPtr = (u32)searchStartAddr; // start of rom
29 romDirInfo->romdirPtr = dir_entry; // start of romdir structure
30 romDirInfo->extinfoPtr = (u32)dir_entry + dir_entry[1].fileSize; // start of extinfo
31 return romDirInfo;
32 }
33
34 dir_entry++;
35 offset += sizeof(ROMDIR_ENTRY);
36 }
37
38 // not found
39 romDirInfo->romdirPtr = NULL;
40 return NULL;
41 }
42
43 // find a file in the romdir table and return info about it
44 //
45 // args: info about romdir to search through
46 // filename to search for
47 // structure to get info about file into
48 // returns: a pointer to fileinfo if successful
49 // NULL otherwise
50 ROMFILE_INFO* searchFileInRom(const ROMDIR_INFO* romdirInfo, const char* filename, ROMFILE_INFO* fileinfo)
51 {
52 register ROMDIR_ENTRY* dir_entry;
53 register ext_offset=0, file_offset=0;
54 int i;
55
56 for (dir_entry = romdirInfo->romdirPtr; dir_entry->name[0]; dir_entry++) {
57
58 for(i = 0; i < 10; ++i) {
59 if( filename[i] == 0 )
60 break;
61 if( dir_entry->name[i] != filename[i] ) {
62 i = -1;
63 break;
64 }
65 }
66
67 if (i > 0 ) {
68 fileinfo->entry = dir_entry;
69 fileinfo->fileData = file_offset + romdirInfo->romPtr; // address of file in rom
70 fileinfo->extData = (u32)NULL; // address of extinfo in rom
71
72 if (dir_entry->extSize)
73 fileinfo->extData = ext_offset + romdirInfo->extinfoPtr; // address of extinfo in rom
74 return fileinfo;
75 }
76
77 file_offset += ROUND_UP(dir_entry->fileSize,16);
78 ext_offset += dir_entry->extSize;
79 }
80
81 // error - file not found
82 return NULL;
83 }
84
85 // gets a hex number from *addr and updates the pointer
86 //
87 // args: pointer to string buffer containing a hex number
88 // returns: the value of the hex number
89 u32 getHexNumber(char** addr)
90 {
91 register char *p; //a1
92 register u32 h = 0; //a2;
93
94 for (p=*addr; *p >= '0'; p++)
95 {
96 int num;
97 if(*p <= '9') num = *p - '0';
98 else if(*p >= 'a') num = *p - 'a' + 10;
99 else num = *p - 'A' + 10;
100
101 h = h*16 + num;
102 }
103
104 *addr = p;
105 return h;
106 }

  ViewVC Help
Powered by ViewVC 1.1.22