mirror of
https://github.com/sanni/cartreader.git
synced 2025-02-17 13:36:19 +01:00
Auto format
This commit is contained in:
parent
30d880bfa7
commit
a8a981e137
@ -76,25 +76,60 @@ char ver[5] = "11.0";
|
|||||||
//******************************************
|
//******************************************
|
||||||
// ENABLE MODULES
|
// ENABLE MODULES
|
||||||
//******************************************
|
//******************************************
|
||||||
// remove // before #define to enable a module
|
// add/remove // before #define to disable/enable modules you
|
||||||
#define enable_SNES
|
// don't need/need to save programm storage space and dynamic memory
|
||||||
#define enable_SFM
|
|
||||||
#define enable_SV
|
// ColecoVision
|
||||||
#define enable_MD
|
#define enable_COLV
|
||||||
#define enable_SMS
|
|
||||||
#define enable_N64
|
// Flashrom Programmer for SNES repros
|
||||||
#define enable_GBX
|
|
||||||
#define enable_NES
|
|
||||||
#define enable_FLASH
|
#define enable_FLASH
|
||||||
#define enable_FLASH16
|
//#define enable_FLASH16
|
||||||
// #define enable_PCE
|
|
||||||
// #define enable_WS
|
// Game Boy (Color) and Advance
|
||||||
// #define enable_NGP
|
#define enable_GBX
|
||||||
// #define enable_INTV
|
|
||||||
// #define enable_COLV
|
// Intellivision
|
||||||
// #define enable_VBOY
|
#define enable_INTV
|
||||||
// #define enable_WSV
|
|
||||||
// #define enable_PCW
|
// Sega Mega Drive/Genesis
|
||||||
|
#define enable_MD
|
||||||
|
|
||||||
|
// Nintendo 64
|
||||||
|
#define enable_N64
|
||||||
|
|
||||||
|
// Nintendo Entertainment System/Family Computer
|
||||||
|
#define enable_NES
|
||||||
|
|
||||||
|
// Neo Geo Pocket
|
||||||
|
#define enable_NGP
|
||||||
|
|
||||||
|
// PC Engine/TurboGrafx 16
|
||||||
|
#define enable_PCE
|
||||||
|
|
||||||
|
// Benesse Pocket Challenge W
|
||||||
|
//#define enable_PCW
|
||||||
|
|
||||||
|
// Sega Master System
|
||||||
|
#define enable_SMS
|
||||||
|
|
||||||
|
// Super Nintendo
|
||||||
|
#define enable_SNES
|
||||||
|
|
||||||
|
// Super Famicom SF Memory Cassette
|
||||||
|
#define enable_SFM
|
||||||
|
|
||||||
|
// Super Famicom Satellaview
|
||||||
|
#define enable_SV
|
||||||
|
|
||||||
|
// Virtual Boy
|
||||||
|
#define enable_VBOY
|
||||||
|
|
||||||
|
// WonderSwan
|
||||||
|
//#define enable_WS
|
||||||
|
|
||||||
|
// Watara Supervision
|
||||||
|
//#define enable_WSV
|
||||||
|
|
||||||
//******************************************
|
//******************************************
|
||||||
// HW CONFIGS
|
// HW CONFIGS
|
||||||
@ -533,30 +568,31 @@ static const uint32_t crc_32_tab[] PROGMEM = { /* CRC polynomial 0xedb88320 */
|
|||||||
|
|
||||||
// Defined as a macros, as compiler disregards inlining requests and these are
|
// Defined as a macros, as compiler disregards inlining requests and these are
|
||||||
// performance-critical functions.
|
// performance-critical functions.
|
||||||
#define UPDATE_CRC(crc, ch) do { \
|
#define UPDATE_CRC(crc, ch) \
|
||||||
uint8_t idx = ((crc) ^ (ch)) & 0xff; \
|
do { \
|
||||||
uint32_t tab_value = pgm_read_dword(crc_32_tab + idx); \
|
uint8_t idx = ((crc) ^ (ch)) & 0xff; \
|
||||||
(crc) = tab_value ^ ((crc) >> 8); \
|
uint32_t tab_value = pgm_read_dword(crc_32_tab + idx); \
|
||||||
} while (0)
|
(crc) = tab_value ^ ((crc) >> 8); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
uint32_t updateCRC(const byte *buffer, size_t length, uint32_t crc) {
|
uint32_t updateCRC(const byte* buffer, size_t length, uint32_t crc) {
|
||||||
for (size_t c = 0; c < length; c++) {
|
for (size_t c = 0; c < length; c++) {
|
||||||
UPDATE_CRC(crc, buffer[c]);
|
UPDATE_CRC(crc, buffer[c]);
|
||||||
}
|
}
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t calculateCRC(const byte *buffer, size_t length) {
|
uint32_t calculateCRC(const byte* buffer, size_t length) {
|
||||||
uint32_t crc = 0xFFFFFFFF;
|
uint32_t crc = 0xFFFFFFFF;
|
||||||
crc = updateCRC(buffer, length, crc);
|
crc = updateCRC(buffer, length, crc);
|
||||||
return ~crc;
|
return ~crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t calculateCRC(FsFile &infile) {
|
uint32_t calculateCRC(FsFile& infile) {
|
||||||
uint32_t byte_count;
|
uint32_t byte_count;
|
||||||
uint32_t crc = 0xFFFFFFFF;
|
uint32_t crc = 0xFFFFFFFF;
|
||||||
|
|
||||||
while((byte_count = infile.read(sdBuffer, sizeof(sdBuffer))) != 0) {
|
while ((byte_count = infile.read(sdBuffer, sizeof(sdBuffer))) != 0) {
|
||||||
crc = updateCRC(sdBuffer, byte_count, crc);
|
crc = updateCRC(sdBuffer, byte_count, crc);
|
||||||
}
|
}
|
||||||
return ~crc;
|
return ~crc;
|
||||||
@ -618,7 +654,7 @@ void get_line(char* str_buf, FsFile* readfile, uint8_t maxi) {
|
|||||||
//if end of file or newline found, execute command
|
//if end of file or newline found, execute command
|
||||||
if (str_buf[i] == '\r') {
|
if (str_buf[i] == '\r') {
|
||||||
str_buf[i] = 0;
|
str_buf[i] = 0;
|
||||||
readfile->seekCur(i - read_len + 2); // +2 to skip over \n because \r\n
|
readfile->seekCur(i - read_len + 2); // +2 to skip over \n because \r\n
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -626,13 +662,13 @@ void get_line(char* str_buf, FsFile* readfile, uint8_t maxi) {
|
|||||||
// EOL was not found, keep looking (slower)
|
// EOL was not found, keep looking (slower)
|
||||||
while (readfile->available()) {
|
while (readfile->available()) {
|
||||||
if (readfile->read() == '\r') {
|
if (readfile->read() == '\r') {
|
||||||
readfile->read(); // read \n because \r\n
|
readfile->read(); // read \n because \r\n
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rewind_line(FsFile &readfile, byte count=1) {
|
void rewind_line(FsFile& readfile, byte count = 1) {
|
||||||
uint32_t position = readfile.curPosition();
|
uint32_t position = readfile.curPosition();
|
||||||
count++;
|
count++;
|
||||||
for (byte count_newline = 0; count_newline < count; count_newline++) {
|
for (byte count_newline = 0; count_newline < count; count_newline++) {
|
||||||
@ -700,7 +736,7 @@ boolean compareCRC(const char* database, char* crcString, boolean renamerom, int
|
|||||||
//Skip CRLF
|
//Skip CRLF
|
||||||
myFile.seekCur(4);
|
myFile.seekCur(4);
|
||||||
}
|
}
|
||||||
#endif // enable_NES
|
#endif // enable_NES
|
||||||
|
|
||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
@ -718,7 +754,7 @@ boolean compareCRC(const char* database, char* crcString, boolean renamerom, int
|
|||||||
}
|
}
|
||||||
myFile.close();
|
myFile.close();
|
||||||
}
|
}
|
||||||
#endif // enable_NES
|
#endif // enable_NES
|
||||||
print_Msg(F(" -> "));
|
print_Msg(F(" -> "));
|
||||||
display_Update();
|
display_Update();
|
||||||
|
|
||||||
@ -749,9 +785,9 @@ boolean compareCRC(const char* database, char* crcString, boolean renamerom, int
|
|||||||
println_Msg(F("Database missing"));
|
println_Msg(F("Database missing"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else // nointro
|
#else // nointro
|
||||||
println_Msg("");
|
println_Msg("");
|
||||||
#endif // !nointro
|
#endif // !nointro
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1886,7 +1922,7 @@ void setColor_RGB(byte r, byte g, byte b) {
|
|||||||
|
|
||||||
// Extract ASCII printable characters from input, collapsing underscores and spaces.
|
// Extract ASCII printable characters from input, collapsing underscores and spaces.
|
||||||
// Use when extracting titles from cartridges, to build a rom title.
|
// Use when extracting titles from cartridges, to build a rom title.
|
||||||
byte buildRomName(char *output, const byte *input, byte length) {
|
byte buildRomName(char* output, const byte* input, byte length) {
|
||||||
byte input_char;
|
byte input_char;
|
||||||
byte output_len = 0;
|
byte output_len = 0;
|
||||||
for (unsigned int i = 0; i < length; i++) {
|
for (unsigned int i = 0; i < length; i++) {
|
||||||
@ -1900,10 +1936,7 @@ byte buildRomName(char *output, const byte *input, byte length) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (
|
while (
|
||||||
output_len && (
|
output_len && (output[output_len - 1] == '_' || output[output_len - 1] == ' ')) {
|
||||||
output[output_len - 1] == '_' || output[output_len - 1] == ' '
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
output_len--;
|
output_len--;
|
||||||
}
|
}
|
||||||
output[output_len] = 0;
|
output[output_len] = 0;
|
||||||
@ -2359,7 +2392,7 @@ void statusLED(boolean on) {
|
|||||||
PORTD |= (1 << 7);
|
PORTD |= (1 << 7);
|
||||||
else
|
else
|
||||||
PORTD &= ~(1 << 7);
|
PORTD &= ~(1 << 7);
|
||||||
/*
|
/*
|
||||||
#elif defined(enable_OLED)
|
#elif defined(enable_OLED)
|
||||||
if (!on)
|
if (!on)
|
||||||
PORTB |= (1 << 4);
|
PORTB |= (1 << 4);
|
||||||
@ -2384,7 +2417,7 @@ void statusLED(boolean on) {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void statusLED(boolean on __attribute__ ((unused))) {
|
void statusLED(boolean on __attribute__((unused))) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -3326,4 +3359,4 @@ void loop() {
|
|||||||
|
|
||||||
//******************************************
|
//******************************************
|
||||||
// End of File
|
// End of File
|
||||||
//******************************************
|
//******************************************
|
@ -903,9 +903,7 @@ void getCartInfo_GB() {
|
|||||||
|
|
||||||
// Strip trailing white space
|
// Strip trailing white space
|
||||||
while (
|
while (
|
||||||
myLength &&
|
myLength && (romName[myLength - 1] == '_' || romName[myLength - 1] == ' ')) {
|
||||||
(romName[myLength - 1] == '_' || romName[myLength - 1] == ' ')
|
|
||||||
) {
|
|
||||||
myLength--;
|
myLength--;
|
||||||
}
|
}
|
||||||
romName[myLength] = 0;
|
romName[myLength] = 0;
|
||||||
@ -918,34 +916,16 @@ void getCartInfo_GB() {
|
|||||||
// MMM01 (Mani 4 in 1)
|
// MMM01 (Mani 4 in 1)
|
||||||
if (
|
if (
|
||||||
(
|
(
|
||||||
strncmp(romName, "BOUKENJIMA2 SET", 15) == 0 && sdBuffer[0x14D] == 0
|
strncmp(romName, "BOUKENJIMA2 SET", 15) == 0 && sdBuffer[0x14D] == 0)
|
||||||
) || (
|
|| (strncmp(romName, "BUBBLEBOBBLE SET", 16) == 0 && sdBuffer[0x14D] == 0xC6) || (strncmp(romName, "GANBARUGA SET", 13) == 0 && sdBuffer[0x14D] == 0x90) || (strncmp(romName, "RTYPE 2 SET", 11) == 0 && sdBuffer[0x14D] == 0x32)) {
|
||||||
strncmp(romName, "BUBBLEBOBBLE SET", 16) == 0 && sdBuffer[0x14D] == 0xC6
|
|
||||||
) || (
|
|
||||||
strncmp(romName, "GANBARUGA SET", 13) == 0 && sdBuffer[0x14D] == 0x90
|
|
||||||
) || (
|
|
||||||
strncmp(romName, "RTYPE 2 SET", 11) == 0 && sdBuffer[0x14D] == 0x32
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
romType = 0x0B;
|
romType = 0x0B;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MBC1M
|
// MBC1M
|
||||||
if (
|
if (
|
||||||
(
|
(
|
||||||
strncmp(romName, "MOMOCOL", 7) == 0 && sdBuffer[0x14D] == 0x28
|
strncmp(romName, "MOMOCOL", 7) == 0 && sdBuffer[0x14D] == 0x28)
|
||||||
) || (
|
|| (strncmp(romName, "BOMCOL", 6) == 0 && sdBuffer[0x14D] == 0x86) || (strncmp(romName, "GENCOL", 6) == 0 && sdBuffer[0x14D] == 0x8A) || (strncmp(romName, "SUPERCHINESE 123", 16) == 0 && sdBuffer[0x14D] == 0xE4) || (strncmp(romName, "MORTALKOMBATI&II", 16) == 0 && sdBuffer[0x14D] == 0xB9) || (strncmp(romName, "MORTALKOMBAT DUO", 16) == 0 && sdBuffer[0x14D] == 0xA7)) {
|
||||||
strncmp(romName, "BOMCOL", 6) == 0 && sdBuffer[0x14D] == 0x86
|
|
||||||
) || (
|
|
||||||
strncmp(romName, "GENCOL", 6) == 0 && sdBuffer[0x14D] == 0x8A
|
|
||||||
) || (
|
|
||||||
strncmp(romName, "SUPERCHINESE 123", 16) == 0 && sdBuffer[0x14D] == 0xE4
|
|
||||||
) || (
|
|
||||||
strncmp(romName, "MORTALKOMBATI&II", 16) == 0 && sdBuffer[0x14D] == 0xB9
|
|
||||||
) || (
|
|
||||||
strncmp(romName, "MORTALKOMBAT DUO", 16) == 0 && sdBuffer[0x14D] == 0xA7
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
romType += 0x100;
|
romType += 0x100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ void gbaMenu() {
|
|||||||
case 0:
|
case 0:
|
||||||
// Read rom
|
// Read rom
|
||||||
if (cartSize == 0) {
|
if (cartSize == 0) {
|
||||||
const byte romOptionsGBASize[] = {1, 2, 4, 8, 16, 32};
|
const byte romOptionsGBASize[] = { 1, 2, 4, 8, 16, 32 };
|
||||||
// create submenu with title and 4 options to choose from
|
// create submenu with title and 4 options to choose from
|
||||||
unsigned char GBARomMenu;
|
unsigned char GBARomMenu;
|
||||||
// Copy menuOptions out of progmem
|
// Copy menuOptions out of progmem
|
||||||
@ -313,7 +313,7 @@ void setup_GBA() {
|
|||||||
*****************************************/
|
*****************************************/
|
||||||
static byte getSaveType() {
|
static byte getSaveType() {
|
||||||
if (saveType == 0) {
|
if (saveType == 0) {
|
||||||
const byte saveOptionsGBAType[] = {1, 2, 3, 6, 4, 5};
|
const byte saveOptionsGBAType[] = { 1, 2, 3, 6, 4, 5 };
|
||||||
// create submenu with title and 6 options to choose from
|
// create submenu with title and 6 options to choose from
|
||||||
unsigned char GBASaveMenu;
|
unsigned char GBASaveMenu;
|
||||||
// Copy menuOptions out of progmem
|
// Copy menuOptions out of progmem
|
||||||
|
@ -12,22 +12,21 @@
|
|||||||
static const char gbSmartMenuItem1[] PROGMEM = "Game Menu";
|
static const char gbSmartMenuItem1[] PROGMEM = "Game Menu";
|
||||||
static const char gbSmartMenuItem2[] PROGMEM = "Flash Menu";
|
static const char gbSmartMenuItem2[] PROGMEM = "Flash Menu";
|
||||||
//static const char gbSmartMenuItem3[] PROGMEM = "Reset"; (stored in common strings array)
|
//static const char gbSmartMenuItem3[] PROGMEM = "Reset"; (stored in common strings array)
|
||||||
static const char* const menuOptionsGBSmart[] PROGMEM = { gbSmartMenuItem1, gbSmartMenuItem2, string_reset2 };
|
static const char *const menuOptionsGBSmart[] PROGMEM = { gbSmartMenuItem1, gbSmartMenuItem2, string_reset2 };
|
||||||
|
|
||||||
static const char gbSmartFlashMenuItem1[] PROGMEM = "Read Flash";
|
static const char gbSmartFlashMenuItem1[] PROGMEM = "Read Flash";
|
||||||
static const char gbSmartFlashMenuItem2[] PROGMEM = "Write Flash";
|
static const char gbSmartFlashMenuItem2[] PROGMEM = "Write Flash";
|
||||||
static const char gbSmartFlashMenuItem3[] PROGMEM = "Back";
|
static const char gbSmartFlashMenuItem3[] PROGMEM = "Back";
|
||||||
static const char* const menuOptionsGBSmartFlash[] PROGMEM = { gbSmartFlashMenuItem1, gbSmartFlashMenuItem2, gbSmartFlashMenuItem3 };
|
static const char *const menuOptionsGBSmartFlash[] PROGMEM = { gbSmartFlashMenuItem1, gbSmartFlashMenuItem2, gbSmartFlashMenuItem3 };
|
||||||
|
|
||||||
static const char gbSmartGameMenuItem1[] PROGMEM = "Read Game";
|
static const char gbSmartGameMenuItem1[] PROGMEM = "Read Game";
|
||||||
static const char gbSmartGameMenuItem2[] PROGMEM = "Read SRAM";
|
static const char gbSmartGameMenuItem2[] PROGMEM = "Read SRAM";
|
||||||
static const char gbSmartGameMenuItem3[] PROGMEM = "Write SRAM";
|
static const char gbSmartGameMenuItem3[] PROGMEM = "Write SRAM";
|
||||||
static const char gbSmartGameMenuItem4[] PROGMEM = "Switch Game";
|
static const char gbSmartGameMenuItem4[] PROGMEM = "Switch Game";
|
||||||
//static const char gbSmartGameMenuItem5[] PROGMEM = "Reset"; (stored in common strings array)
|
//static const char gbSmartGameMenuItem5[] PROGMEM = "Reset"; (stored in common strings array)
|
||||||
static const char* const menuOptionsGBSmartGame[] PROGMEM = { gbSmartGameMenuItem1, gbSmartGameMenuItem2, gbSmartGameMenuItem3, gbSmartGameMenuItem4, string_reset2 };
|
static const char *const menuOptionsGBSmartGame[] PROGMEM = { gbSmartGameMenuItem1, gbSmartGameMenuItem2, gbSmartGameMenuItem3, gbSmartGameMenuItem4, string_reset2 };
|
||||||
|
|
||||||
struct GBSmartGameInfo
|
struct GBSmartGameInfo {
|
||||||
{
|
|
||||||
uint8_t start_bank;
|
uint8_t start_bank;
|
||||||
uint8_t rom_type;
|
uint8_t rom_type;
|
||||||
uint8_t rom_size;
|
uint8_t rom_size;
|
||||||
|
@ -858,7 +858,7 @@ void setCart_INTV() {
|
|||||||
myFile.seekCur(1);
|
myFile.seekCur(1);
|
||||||
|
|
||||||
// Read SRAM size
|
// Read SRAM size
|
||||||
byte sramSize __attribute__ ((unused)) = myFile.read() - 48;
|
byte sramSize __attribute__((unused)) = myFile.read() - 48;
|
||||||
|
|
||||||
// Skip rest of line
|
// Skip rest of line
|
||||||
myFile.seekCur(2);
|
myFile.seekCur(2);
|
||||||
|
@ -667,16 +667,14 @@ void dataIn_MD() {
|
|||||||
/******************************************
|
/******************************************
|
||||||
MEGA DRIVE functions
|
MEGA DRIVE functions
|
||||||
*****************************************/
|
*****************************************/
|
||||||
byte copyToRomName_MD(char *output, const byte *input, byte length) {
|
byte copyToRomName_MD(char* output, const byte* input, byte length) {
|
||||||
byte myLength = 0;
|
byte myLength = 0;
|
||||||
|
|
||||||
for (byte i = 0; i < 48; i++) {
|
for (byte i = 0; i < 48; i++) {
|
||||||
if (
|
if (
|
||||||
(
|
(
|
||||||
(input[i] >= '0' && input[i] <= '9') ||
|
(input[i] >= '0' && input[i] <= '9') || (input[i] >= 'A' && input[i] <= 'z'))
|
||||||
(input[i] >= 'A' && input[i] <= 'z')
|
&& myLength < length) {
|
||||||
) && myLength < length
|
|
||||||
) {
|
|
||||||
output[myLength++] = input[i];
|
output[myLength++] = input[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1726,7 +1726,7 @@ void verifyCRC() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculates the checksum of the header
|
// Calculates the checksum of the header
|
||||||
boolean checkHeader(byte *buf) {
|
boolean checkHeader(byte* buf) {
|
||||||
word sum = 0;
|
word sum = 0;
|
||||||
word buf_sum = (buf[28] << 8) + buf[29];
|
word buf_sum = (buf[28] << 8) + buf[29];
|
||||||
|
|
||||||
@ -4850,4 +4850,4 @@ unsigned long verifyGameshark_N64() {
|
|||||||
|
|
||||||
//******************************************
|
//******************************************
|
||||||
// End of File
|
// End of File
|
||||||
//******************************************
|
//******************************************
|
@ -460,9 +460,9 @@ struct database_entry {
|
|||||||
char filename[128];
|
char filename[128];
|
||||||
char crc_str[8 + 1 + 8 + 1 + 32 + 1];
|
char crc_str[8 + 1 + 8 + 1 + 32 + 1];
|
||||||
uint32_t crc;
|
uint32_t crc;
|
||||||
char *crc512_str;
|
char* crc512_str;
|
||||||
uint32_t crc512;
|
uint32_t crc512;
|
||||||
char *iNES_str;
|
char* iNES_str;
|
||||||
};
|
};
|
||||||
|
|
||||||
void printPRG(unsigned long myOffset) {
|
void printPRG(unsigned long myOffset) {
|
||||||
@ -495,7 +495,7 @@ void setDefaultRomName() {
|
|||||||
romName[4] = '\0';
|
romName[4] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRomnameFromString(const char *input) {
|
void setRomnameFromString(const char* input) {
|
||||||
byte myLength = 0;
|
byte myLength = 0;
|
||||||
for (byte i = 0; i < 20 && myLength < 15; i++) {
|
for (byte i = 0; i < 20 && myLength < 15; i++) {
|
||||||
// Stop at first "(" to remove "(Country)"
|
// Stop at first "(" to remove "(Country)"
|
||||||
@ -503,10 +503,7 @@ void setRomnameFromString(const char *input) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
(input[i] >= '0' && input[i] <= '9') ||
|
(input[i] >= '0' && input[i] <= '9') || (input[i] >= 'A' && input[i] <= 'Z') || (input[i] >= 'a' && input[i] <= 'z')) {
|
||||||
(input[i] >= 'A' && input[i] <= 'Z') ||
|
|
||||||
(input[i] >= 'a' && input[i] <= 'z')
|
|
||||||
) {
|
|
||||||
romName[myLength++] = input[i];
|
romName[myLength++] = input[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -568,10 +565,7 @@ void getMapping() {
|
|||||||
readDatabaseEntry(database, &entry);
|
readDatabaseEntry(database, &entry);
|
||||||
//if checksum search was successful set mapper and end search, also filter out 0xFF checksum
|
//if checksum search was successful set mapper and end search, also filter out 0xFF checksum
|
||||||
if (
|
if (
|
||||||
entry.crc512 != 0xBD7BC39F && (
|
entry.crc512 != 0xBD7BC39F && (entry.crc512 == oldcrc32 || entry.crc512 == oldcrc32MMC3)) {
|
||||||
entry.crc512 == oldcrc32 || entry.crc512 == oldcrc32MMC3
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
// Rewind to start of entry
|
// Rewind to start of entry
|
||||||
rewind_line(database, 3);
|
rewind_line(database, 3);
|
||||||
break;
|
break;
|
||||||
@ -597,8 +591,8 @@ void getMapping() {
|
|||||||
// Display database
|
// Display database
|
||||||
while (database.available()) {
|
while (database.available()) {
|
||||||
byte iNES[16];
|
byte iNES[16];
|
||||||
byte *output;
|
byte* output;
|
||||||
char *input;
|
char* input;
|
||||||
|
|
||||||
struct database_entry entry;
|
struct database_entry entry;
|
||||||
|
|
||||||
@ -709,7 +703,7 @@ void getMapping() {
|
|||||||
database.close();
|
database.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void readDatabaseEntry(FsFile &database, struct database_entry *entry) {
|
static void readDatabaseEntry(FsFile& database, struct database_entry* entry) {
|
||||||
get_line(entry->filename, &database, sizeof(entry->filename));
|
get_line(entry->filename, &database, sizeof(entry->filename));
|
||||||
get_line(entry->crc_str, &database, sizeof(entry->crc_str));
|
get_line(entry->crc_str, &database, sizeof(entry->crc_str));
|
||||||
skip_line(&database);
|
skip_line(&database);
|
||||||
@ -724,7 +718,7 @@ static void readDatabaseEntry(FsFile &database, struct database_entry *entry) {
|
|||||||
entry->crc512 = strtoul(entry->crc512_str, NULL, 16);
|
entry->crc512 = strtoul(entry->crc512_str, NULL, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void selectMapping(FsFile &database) {
|
static void selectMapping(FsFile& database) {
|
||||||
// Select starting letter
|
// Select starting letter
|
||||||
byte myLetter = starting_letter();
|
byte myLetter = starting_letter();
|
||||||
|
|
||||||
@ -2511,10 +2505,10 @@ void readPRG(boolean readrom) {
|
|||||||
case 0:
|
case 0:
|
||||||
case 3:
|
case 3:
|
||||||
case 13:
|
case 13:
|
||||||
case 87: // 16K/32K
|
case 87: // 16K/32K
|
||||||
case 184: // 32K
|
case 184: // 32K
|
||||||
case 185: // 16K/32K
|
case 185: // 16K/32K
|
||||||
for (word address = 0; address < (((word) prgsize) * 0x4000) + 0x4000; address += 512) { // 16K or 32K
|
for (word address = 0; address < (((word)prgsize) * 0x4000) + 0x4000; address += 512) { // 16K or 32K
|
||||||
dumpPRG(base, address);
|
dumpPRG(base, address);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2542,7 +2536,7 @@ void readPRG(boolean readrom) {
|
|||||||
case 2: // 128K/256K
|
case 2: // 128K/256K
|
||||||
for (int i = 0; i < 8; i++) { // 128K/256K
|
for (int i = 0; i < 8; i++) { // 128K/256K
|
||||||
write_prg_byte(0x8000, i);
|
write_prg_byte(0x8000, i);
|
||||||
for (word address = 0x0; address < (((word) prgsize - 3) * 0x4000) + 0x4000; address += 512) {
|
for (word address = 0x0; address < (((word)prgsize - 3) * 0x4000) + 0x4000; address += 512) {
|
||||||
dumpPRG(base, address);
|
dumpPRG(base, address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2760,13 +2754,13 @@ void readPRG(boolean readrom) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 36:
|
case 36:
|
||||||
banks = int_pow(2, prgsize) / 2;
|
banks = int_pow(2, prgsize) / 2;
|
||||||
for (int i = 0; i < banks; i++) {
|
for (int i = 0; i < banks; i++) {
|
||||||
write_prg_byte(0xFFA0+i, (i<<4));
|
write_prg_byte(0xFFA0 + i, (i << 4));
|
||||||
write_prg_byte(0x4101, 0);
|
write_prg_byte(0x4101, 0);
|
||||||
write_prg_byte(0x4102, (i<<4));
|
write_prg_byte(0x4102, (i << 4));
|
||||||
write_prg_byte(0x4103, 0);
|
write_prg_byte(0x4103, 0);
|
||||||
write_prg_byte(0x4100, 0);
|
write_prg_byte(0x4100, 0);
|
||||||
write_prg_byte(0x4103, 0xFF);
|
write_prg_byte(0x4103, 0xFF);
|
||||||
@ -3014,10 +3008,10 @@ void readPRG(boolean readrom) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 91:
|
case 91:
|
||||||
banks = int_pow(2, prgsize);
|
banks = int_pow(2, prgsize);
|
||||||
for (int i = 0; i < (banks-2); i += 2) {
|
for (int i = 0; i < (banks - 2); i += 2) {
|
||||||
write_prg_byte(0x7000, (i | 0));
|
write_prg_byte(0x7000, (i | 0));
|
||||||
write_prg_byte(0x7001, (i | 1));
|
write_prg_byte(0x7001, (i | 1));
|
||||||
for (word address = 0x0; address < 0x4000; address += 512) {
|
for (word address = 0x0; address < 0x4000; address += 512) {
|
||||||
@ -3025,8 +3019,8 @@ void readPRG(boolean readrom) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (word address = 0x4000; address < 0x8000; address += 512) {
|
for (word address = 0x4000; address < 0x8000; address += 512) {
|
||||||
dumpPRG(base, address);
|
dumpPRG(base, address);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 92: // 256K
|
case 92: // 256K
|
||||||
@ -3566,7 +3560,7 @@ void readCHR(boolean readrom) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 36:
|
case 36:
|
||||||
banks = int_pow(2, chrsize) * 4;
|
banks = int_pow(2, chrsize) * 4;
|
||||||
for (int i = 0; i < banks; i++) {
|
for (int i = 0; i < banks; i++) {
|
||||||
@ -3850,14 +3844,14 @@ void readCHR(boolean readrom) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 91:
|
case 91:
|
||||||
banks = int_pow(2, chrsize) / 2;
|
banks = int_pow(2, chrsize) / 2;
|
||||||
for (int i = 0; i < banks; i += 8) {
|
for (int i = 0; i < banks; i += 8) {
|
||||||
write_prg_byte(0x6000, (i/2) | 0);
|
write_prg_byte(0x6000, (i / 2) | 0);
|
||||||
write_prg_byte(0x6001, (i/2) | 1);
|
write_prg_byte(0x6001, (i / 2) | 1);
|
||||||
write_prg_byte(0x6002, (i/2) | 2);
|
write_prg_byte(0x6002, (i / 2) | 2);
|
||||||
write_prg_byte(0x6003, (i/2) | 3);
|
write_prg_byte(0x6003, (i / 2) | 3);
|
||||||
for (word address = 0x0; address < 0x2000; address += 512) {
|
for (word address = 0x0; address < 0x2000; address += 512) {
|
||||||
dumpCHR(address);
|
dumpCHR(address);
|
||||||
}
|
}
|
||||||
@ -4666,8 +4660,8 @@ void NESmaker_ID() { // Read Flash ID
|
|||||||
write_prg_byte(0xC000, 0x00);
|
write_prg_byte(0xC000, 0x00);
|
||||||
write_prg_byte(0xAAAA, 0x55);
|
write_prg_byte(0xAAAA, 0x55);
|
||||||
write_prg_byte(0xC000, 0x01);
|
write_prg_byte(0xC000, 0x01);
|
||||||
write_prg_byte(0x9555, 0xF0); // Software ID Exit
|
write_prg_byte(0x9555, 0xF0); // Software ID Exit
|
||||||
if (flashid == 0xBFB7) // SST 39SF040
|
if (flashid == 0xBFB7) // SST 39SF040
|
||||||
flashfound = 1;
|
flashfound = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4807,4 +4801,4 @@ void writeFLASH() {
|
|||||||
#endif
|
#endif
|
||||||
//******************************************
|
//******************************************
|
||||||
// End of File
|
// End of File
|
||||||
//******************************************
|
//******************************************
|
@ -60,12 +60,12 @@ static const char *const menuOptionspce[] PROGMEM = { pceMenuItem1, pceMenuItem2
|
|||||||
// PCE card menu items
|
// PCE card menu items
|
||||||
static char menuOptionspceCart[7][20] = {
|
static char menuOptionspceCart[7][20] = {
|
||||||
"Read ROM",
|
"Read ROM",
|
||||||
"", // Read RAM Bank %d
|
"", // Read RAM Bank %d
|
||||||
"", //Write RAM Bank %d
|
"", //Write RAM Bank %d
|
||||||
"Reset",
|
"Reset",
|
||||||
"Inc Bank Number",
|
"Inc Bank Number",
|
||||||
"Dec Bank Number",
|
"Dec Bank Number",
|
||||||
"" // ROM size now %dK / Force ROM size
|
"" // ROM size now %dK / Force ROM size
|
||||||
};
|
};
|
||||||
|
|
||||||
// Turbochip menu items
|
// Turbochip menu items
|
||||||
@ -440,7 +440,7 @@ uint32_t calculate_crc32(int n, unsigned char c[], uint32_t r) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void crc_search(char *file_p, char *folder_p, uint32_t rom_size __attribute__ ((unused)), uint32_t crc) {
|
void crc_search(char *file_p, char *folder_p, uint32_t rom_size __attribute__((unused)), uint32_t crc) {
|
||||||
FsFile rom, script;
|
FsFile rom, script;
|
||||||
char gamename[100];
|
char gamename[100];
|
||||||
char crc_file[9], crc_search[9];
|
char crc_file[9], crc_search[9];
|
||||||
|
@ -433,7 +433,7 @@ void sfmFlashMenu() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Read the games from the menu area
|
// Read the games from the menu area
|
||||||
void getGames(char gameCode[8][20], boolean *hasMenu, byte *numGames) {
|
void getGames(char gameCode[8][20], boolean* hasMenu, byte* numGames) {
|
||||||
// Set data pins to input
|
// Set data pins to input
|
||||||
dataIn();
|
dataIn();
|
||||||
// Set control pins to input
|
// Set control pins to input
|
||||||
@ -1751,4 +1751,4 @@ void write_SFM(int startBank, uint32_t pos) {
|
|||||||
|
|
||||||
//******************************************
|
//******************************************
|
||||||
// End of File
|
// End of File
|
||||||
//******************************************
|
//******************************************
|
Loading…
x
Reference in New Issue
Block a user