mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-13 08:25:05 +01:00
Switched to 32-bit sizes
This commit is contained in:
parent
52894e5c2f
commit
97e5e21962
@ -734,8 +734,15 @@ void outputNES() {
|
|||||||
display_Clear();
|
display_Clear();
|
||||||
char* outputFile;
|
char* outputFile;
|
||||||
unsigned long crcOffset = 0;
|
unsigned long crcOffset = 0;
|
||||||
|
uint32_t prg_size_bytes = 1024 * (uint32_t)prg;
|
||||||
|
uint32_t chr_size_bytes = 1024 * (uint32_t)chr;
|
||||||
|
int has_header = 0;
|
||||||
|
|
||||||
unsigned char* nes_header_bytes = getNESHeaderForFileInfo(1024 * prg, 1024 * chr, prg_crc32, chr_crc32);
|
unsigned char* nes_header_bytes = getNESHeaderForFileInfo(prg_size_bytes, chr_size_bytes, prg_crc32, chr_crc32);
|
||||||
|
|
||||||
|
if (nes_header_bytes != NULL) {
|
||||||
|
has_header = 1;
|
||||||
|
}
|
||||||
|
|
||||||
LED_RED_ON;
|
LED_RED_ON;
|
||||||
LED_GREEN_ON;
|
LED_GREEN_ON;
|
||||||
@ -751,7 +758,7 @@ void outputNES() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nes_header_bytes != NULL) {
|
if (has_header) {
|
||||||
outputFile = fileNES;
|
outputFile = fileNES;
|
||||||
crcOffset = 16;
|
crcOffset = 16;
|
||||||
} else {
|
} else {
|
||||||
@ -771,7 +778,7 @@ void outputNES() {
|
|||||||
print_Error(F("SD Error"), true);
|
print_Error(F("SD Error"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nes_header_bytes != NULL)
|
if (has_header)
|
||||||
{
|
{
|
||||||
nesFile.write(nes_header_bytes, 16);
|
nesFile.write(nes_header_bytes, 16);
|
||||||
free(nes_header_bytes);
|
free(nes_header_bytes);
|
||||||
@ -805,7 +812,11 @@ void outputNES() {
|
|||||||
nesFile.close();
|
nesFile.close();
|
||||||
|
|
||||||
display_Clear();
|
display_Clear();
|
||||||
println_Msg(F("NES FILE OUTPUT!"));
|
if (has_header) {
|
||||||
|
println_Msg(F("NES FILE OUTPUT!"));
|
||||||
|
} else {
|
||||||
|
println_Msg(F("BIN FILE OUTPUT!"));
|
||||||
|
}
|
||||||
println_Msg(F(""));
|
println_Msg(F(""));
|
||||||
display_Update();
|
display_Update();
|
||||||
|
|
||||||
@ -833,7 +844,7 @@ void CartFinish() {
|
|||||||
NES 2.0 Header Functions
|
NES 2.0 Header Functions
|
||||||
*****************************************/
|
*****************************************/
|
||||||
|
|
||||||
unsigned char* getNESHeaderForFileInfo(size_t prg_size, size_t chr_size, uint32_t prg_crc32, uint32_t chr_crc32) {
|
unsigned char* getNESHeaderForFileInfo(uint32_t prg_size, uint32_t chr_size, uint32_t prg_crc32, uint32_t chr_crc32) {
|
||||||
if (prg_size == 0) {
|
if (prg_size == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -856,8 +867,8 @@ unsigned char* getNESHeaderForFileInfo(size_t prg_size, size_t chr_size, uint32_
|
|||||||
// padded with null characters
|
// padded with null characters
|
||||||
sdFile.read(temp_line, 256);
|
sdFile.read(temp_line, 256);
|
||||||
|
|
||||||
size_t prg_size_db;
|
uint32_t prg_size_db;
|
||||||
size_t chr_size_db;
|
uint32_t chr_size_db;
|
||||||
uint32_t prg_crc32_db;
|
uint32_t prg_crc32_db;
|
||||||
uint32_t chr_crc32_db;
|
uint32_t chr_crc32_db;
|
||||||
|
|
||||||
@ -1020,25 +1031,25 @@ uint32_t crc32FromBytes(const unsigned char* bytearr) {
|
|||||||
return (uint32_t)(((uint32_t)bytearr[0] << 24) | ((uint32_t)bytearr[1] << 16) | ((uint32_t)bytearr[2] << 8) | (uint32_t)bytearr[3]);
|
return (uint32_t)(((uint32_t)bytearr[0] << 24) | ((uint32_t)bytearr[1] << 16) | ((uint32_t)bytearr[2] << 8) | (uint32_t)bytearr[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getPRGSizeFromDatabaseRow(const char* crctest) {
|
uint32_t getPRGSizeFromDatabaseRow(const char* crctest) {
|
||||||
char* prg_size_str = getDatabaseFieldFromRow(crctest, 0);
|
char* prg_size_str = getDatabaseFieldFromRow(crctest, 0);
|
||||||
if (prg_size_str == NULL) {
|
if (prg_size_str == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t return_size = (size_t)atoi(prg_size_str);
|
uint32_t return_size = (uint32_t)atoi(prg_size_str);
|
||||||
free(prg_size_str);
|
free(prg_size_str);
|
||||||
|
|
||||||
return return_size;
|
return return_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getCHRSizeFromDatabaseRow(const char* crctest) {
|
uint32_t getCHRSizeFromDatabaseRow(const char* crctest) {
|
||||||
char* chr_size_str = getDatabaseFieldFromRow(crctest, 1);
|
char* chr_size_str = getDatabaseFieldFromRow(crctest, 1);
|
||||||
if (chr_size_str == NULL) {
|
if (chr_size_str == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t return_size = (size_t)atoi(chr_size_str);
|
uint32_t return_size = (uint32_t)atoi(chr_size_str);
|
||||||
free(chr_size_str);
|
free(chr_size_str);
|
||||||
|
|
||||||
return return_size;
|
return return_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user