00001 00002 #ifndef LIB_UNIF_20080314_H_ 00003 #define LIB_UNIF_20080314_H_ 00004 00005 #ifdef __cplusplus 00006 extern "C"{ 00007 #endif 00008 00009 #include "unif_types.h" 00010 00011 #include <stdio.h> 00012 00013 /* the file we read MAY NOT have a revision greater than this */ 00014 #define UNIF_REVISION 0x00000007 00015 00016 /* definitions for the CTRL block */ 00017 #define CTRL_STDJOY 0x01 /* Bit 0: Regular Joypad */ 00018 #define CTRL_ZAPPER 0x02 /* Bit 1: Zapper */ 00019 #define CTRL_ROB 0x04 /* Bit 2: R.O.B */ 00020 #define CTRL_ARKANOID 0x08 /* Bit 3: Arkanoid Controller */ 00021 #define CTRL_POWPAD 0x10 /* Bit 4: Power Pad */ 00022 #define CTRL_4SCORE 0x20 /* Bit 5: Four-Score adapter */ 00023 #define CTRL_RESERVE1 0x40 /* Bit 6: Expansion (Do not touch) */ 00024 #define CTRL_RESERVE2 0x80 /* Bit 7: Expansion (Do not touch) */ 00025 00026 /* header structure */ 00027 typedef struct { 00028 char id[4]; /* MUST be "UNIF", NOT null terminated */ 00029 uint32_t revision; /* Revision number */ 00030 uint8_t expansion[24]; /* reserved */ 00031 } unif_header_t; 00032 00033 00034 /* chunk header */ 00035 typedef struct { 00036 union { 00037 char chunk_id[4]; /* Chunk identification string. */ 00038 uint32_t chunk_nid; /* Can also be considered a 32-bit number */ 00039 } u; 00040 00041 uint32_t length; /* Data length, in little-endian format */ 00042 } unif_chunk_t; 00043 00044 /* handy for reading dumper info */ 00045 typedef struct { 00046 char dumper_name[100]; /* NULL-terminated string containing the name of the 00047 * person who dumped the cart. */ 00048 unsigned char day; /* Day of the month when cartridge was dumped */ 00049 unsigned char month; /* Month of the year when cartridge was dumped */ 00050 unsigned short year; /* Year during which the cartridge was dumped */ 00051 char dumper_agent[100]; /* NULL-terminated string containing the name of 00052 * the ROM-dumping means used */ 00053 } dumper_info_t; 00054 00055 00056 /* function prototypes */ 00057 UNIF_RETURN_CODE open_UNIF(const char *filename, FILE **file, UNIF_OPEN_MODE mode); 00058 UNIF_RETURN_CODE close_UNIF(FILE *file); 00059 00060 UNIF_RETURN_CODE read_header_UNIF(FILE *file, unif_header_t *header); 00061 UNIF_RETURN_CODE write_header_UNIF(FILE *file, unif_header_t *header); 00062 UNIF_RETURN_CODE check_header_UNIF(unif_header_t *header); 00063 00064 UNIF_RETURN_CODE read_chunk_UNIF(FILE *file, unif_chunk_t *chunk_header, void **chunk_data ); 00065 UNIF_RETURN_CODE write_chunk_UNIF(FILE *file, unif_chunk_t *chunk_header, void *chunk_data ); 00066 00067 const char *get_error_string_UNIF(UNIF_RETURN_CODE code); 00068 00069 #ifdef __cplusplus 00070 } 00071 #endif 00072 00073 #endif 00074