PS2SDK
PS2 Homebrew Libraries
romimg.h
1 /*
2  ROMFS format:
3  ROMDIR section
4  EXTINFO section
5  File data section
6  All files will have an entry in all three sections. The ROMDIR section is terminated by an entry that consists of zeros.
7 
8  Required file entries (In this order):
9  RESET (0-byte)
10  ROMDIR (The size of the whole ROMDIR section)
11  EXTINFO (The size of the whole EXTINFO section)
12 
13  The EXTINFO section (Extended Information section) contains more information on the file (E.g. date and version numbers) and comments on the file.
14 
15  The EXTINFO section is also a file! (In fact, all sections are files)
16 
17  All sections and files are (must be?) aligned to 16-byte boundaries, and all records within each section must be aligned to 4-byte boundaries.
18 */
19 
20 #ifndef __ROMING_H__
21 #define __ROMING_H__
22 
23 #include "dprintf.h"
24 #include <stdint.h> // for uintptr_t
25 
26 #define RMIMG_PTRCAST uintptr_t
27 
28 struct RomDirEntry
29 {
30  char name[10];
31  unsigned short int ExtInfoEntrySize;
32  unsigned int size;
33 };
34 
35 /* Each ROMDIR entry can have any combination of EXTINFO fields. */
36 struct ExtInfoFieldEntry
37 {
38  unsigned short int value; /* Only applicable for the version field type. */
39  unsigned char ExtLength; /* The length of data appended to the end of this entry. */
40  unsigned char type;
41 };
42 
43 enum ExtInfoFieldTypes {
44  EXTINFO_FIELD_TYPE_DATE = 1,
45  EXTINFO_FIELD_TYPE_VERSION,
46  EXTINFO_FIELD_TYPE_COMMENT,
47  EXTINFO_FIELD_TYPE_NULL = 0x7F
48 };
49 
50 struct FileEntry
51 {
52  struct RomDirEntry RomDir;
53  unsigned char *ExtInfoData;
54  void *FileData;
55 };
56 
57 typedef struct ImageStructure
58 {
59  unsigned int NumFiles;
60  unsigned int date;
61  char *comment;
62  struct FileEntry *files; // Stores the records of all files, including RESET. Only those entries that are automatically generated like ROMDIR and EXTINFO will be omitted.
63 } ROMIMG;
64 
65 /* Function prototypes */
66 extern int CreateBlankROMImg(const char *filename, ROMIMG *ROMImg);
67 extern int WriteROMImg(const char *file, const ROMIMG *ROMImg);
68 extern int LoadROMImg(ROMIMG *ROMImg, const char *path);
69 extern void UnloadROMImg(ROMIMG *ROMImg);
70 extern int AddFile(ROMIMG *ROMImg, const char *path, int upperconv);
71 extern int DeleteFile(ROMIMG *ROMImg, const char *filename);
72 extern int ExtractFile(const ROMIMG *ROMImg, const char *filename, const char *FileToExtract);
73 extern int IsFileExists(const ROMIMG *ROMImg, const char *filename);
74 
75 #endif /* __ROMING_H__ */
RomDirEntry
Definition: romdrv.h:39
ExtInfoFieldEntry
Definition: romdrv.h:54
FileEntry
Definition: romimg.h:50
ImageStructure
Definition: romimg.h:57