11 file = fopen(filepath,
"rb");
13 perror(
"Error opening the file !\n");
17 fseek(file, 0, SEEK_END);
19 fseek(file, 0, SEEK_SET);
23 perror(
"Memory allocation failed !\n");
28 size_t result = fread(buff, 1, fsize, file);
29 printf(
"\nRead: %lu\n", result);
30 if (result != fsize) {
31 perror(
"Reading error !\n");
39 unsigned int file_id = (buff[0] << 24) | (buff[1] << 16) | (buff[2] << 8) | (buff[3]);
41 printf(
"Signature is not matching ! %i != %i\n", file_id,
NES_SIGNATURE);
42 printf(
"Only NES ROMs are accepted by this emulator !\n\n");
49 perror(
"Allocation failure !\n");