Merge pull request #86 from Kreeblah/master

Output unheadered NES ROMs as CART.bin
This commit is contained in:
sanni 2021-02-01 08:28:22 +01:00 committed by GitHub
commit c85e61c988

View File

@ -12,17 +12,17 @@
//26 Supported Mappers //26 Supported Mappers
//101 Defines //101 Defines
//131 Variables //131 Variables
//191 Menu //192 Menu
//310 Setup //311 Setup
//339 Low Level Functions //340 Low Level Functions
//586 CRC Functions //587 CRC Functions
//645 File Functions //646 File Functions
//819 NES 2.0 Header Functions //828 NES 2.0 Header Functions
//1100 Config Functions //1109 Config Functions
//1696 ROM Functions //1705 ROM Functions
//2794 RAM Functions //2803 RAM Functions
//3229 Eeprom Functions //3232 Eeprom Functions
//3419 NESmaker Flash Cart Functions //3428 NESmaker Flash Cart Functions
/****************************************** /******************************************
Supported Mappers Supported Mappers
@ -175,6 +175,7 @@ uint32_t chr_crc32;
char filePRG[] = "PRG.bin"; char filePRG[] = "PRG.bin";
char fileCHR[] = "CHR.bin"; char fileCHR[] = "CHR.bin";
char fileNES[] = "CART.nes"; char fileNES[] = "CART.nes";
char fileBIN[] = "CART.bin";
// Cartridge Config // Cartridge Config
byte mapper; byte mapper;
@ -730,6 +731,7 @@ void CreateRAMFileInSD() {
void outputNES() { void outputNES() {
display_Clear(); display_Clear();
char* outputFile;
unsigned char* nes_header_bytes = getNESHeaderForFileInfo(1024 * prg, 1024 * chr, prg_crc32, chr_crc32); unsigned char* nes_header_bytes = getNESHeaderForFileInfo(1024 * prg, 1024 * chr, prg_crc32, chr_crc32);
@ -746,8 +748,15 @@ void outputNES() {
print_Error(F("SD Error"), true); print_Error(F("SD Error"), true);
} }
if (!sd.exists(fileNES)) {
nesFile = sd.open(fileNES, O_RDWR | O_CREAT); if(nes_header_bytes != NULL) {
outputFile = fileNES;
} else {
outputFile = fileBIN;
}
if (!sd.exists(outputFile)) {
nesFile = sd.open(outputFile, O_RDWR | O_CREAT);
} }
if (!nesFile) { if (!nesFile) {
LED_GREEN_OFF; LED_GREEN_OFF;
@ -797,7 +806,7 @@ void outputNES() {
println_Msg(F("")); println_Msg(F(""));
display_Update(); display_Update();
calcCRC(fileNES, (prg + chr) * 1024, NULL); calcCRC(outputFile, (prg + chr) * 1024, NULL);
LED_RED_OFF; LED_RED_OFF;
LED_GREEN_OFF; LED_GREEN_OFF;
LED_BLUE_OFF; LED_BLUE_OFF;