mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-27 15:04:15 +01:00
All: Resolve all compiler and linker warnings
No functional change intended.
This commit is contained in:
parent
d81f2c0509
commit
a555f2117f
@ -564,6 +564,7 @@ uint32_t calculateCRC(char* fileName, char* folder, int offset) {
|
||||
//print_Msg(F("/"));
|
||||
//print_Msg(fileName);
|
||||
print_Error(F(" not found"), true);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -616,7 +617,7 @@ void get_line(char* str_buf, FsFile* readfile, uint8_t maxi) {
|
||||
}
|
||||
|
||||
// Calculate CRC32 if needed and compare it to CRC read from database
|
||||
boolean compareCRC(char* database, char* crcString, boolean renamerom, int offset) {
|
||||
boolean compareCRC(const char* database, char* crcString, boolean renamerom, int offset) {
|
||||
#ifdef nointro
|
||||
char crcStr[9];
|
||||
if (crcString == 0) {
|
||||
@ -661,15 +662,15 @@ boolean compareCRC(char* database, char* crcString, boolean renamerom, int offse
|
||||
get_line(iNES_STR, &myFile, 33);
|
||||
|
||||
// Convert "4E4553" to (0x4E, 0x45, 0x53)
|
||||
byte iNES_BUF[2];
|
||||
unsigned int iNES_BUF;
|
||||
for (byte j = 0; j < 16; j++) {
|
||||
sscanf(iNES_STR + j * 2, "%2X", iNES_BUF);
|
||||
iNES_HEADER[j] = iNES_BUF[0];
|
||||
sscanf(iNES_STR + j * 2, "%2X", &iNES_BUF);
|
||||
iNES_HEADER[j] = iNES_BUF;
|
||||
}
|
||||
//Skip CRLF
|
||||
myFile.seekSet(myFile.curPosition() + 4);
|
||||
}
|
||||
#endif
|
||||
#endif // enable_NES
|
||||
|
||||
// Close the file:
|
||||
myFile.close();
|
||||
@ -687,7 +688,7 @@ boolean compareCRC(char* database, char* crcString, boolean renamerom, int offse
|
||||
}
|
||||
myFile.close();
|
||||
}
|
||||
#endif
|
||||
#endif // enable_NES
|
||||
print_Msg(F(" -> "));
|
||||
display_Update();
|
||||
|
||||
@ -718,9 +719,10 @@ boolean compareCRC(char* database, char* crcString, boolean renamerom, int offse
|
||||
println_Msg(F("Database missing"));
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#else // nointro
|
||||
println_Msg("");
|
||||
#endif
|
||||
#endif // !nointro
|
||||
return 0;
|
||||
}
|
||||
|
||||
byte starting_letter() {
|
||||
@ -1877,7 +1879,7 @@ void print_Error(const __FlashStringHelper* errorMessage, boolean forceReset) {
|
||||
|
||||
if (forceReset) {
|
||||
println_Msg(F(""));
|
||||
println_Msg(F("Press Button..."));
|
||||
print_STR(press_button_STR, 1);
|
||||
display_Update();
|
||||
wait();
|
||||
if (ignoreError == 0) {
|
||||
@ -1997,7 +1999,7 @@ void save_log() {
|
||||
}
|
||||
myFile.write(sdBuffer, 512);
|
||||
} else {
|
||||
word i = 0;
|
||||
int i = 0;
|
||||
for (; i < myLog.available(); i++) {
|
||||
sdBuffer[i] = myLog.read();
|
||||
}
|
||||
@ -2031,7 +2033,7 @@ void print_Msg(const char myString[]) {
|
||||
#if (defined(enable_LCD) || defined(enable_OLED))
|
||||
// test for word wrap
|
||||
if ((display.tx + strlen(myString) * 6) > 128) {
|
||||
int strPos = 0;
|
||||
unsigned int strPos = 0;
|
||||
// Print until end of display
|
||||
while (display.tx < 122) {
|
||||
display.print(myString[strPos]);
|
||||
@ -2174,7 +2176,7 @@ void println_Msg(const char myString[]) {
|
||||
#if (defined(enable_LCD) || defined(enable_OLED))
|
||||
// test for word wrap
|
||||
if ((display.tx + strlen(myString) * 6) > 128) {
|
||||
int strPos = 0;
|
||||
unsigned int strPos = 0;
|
||||
// Print until end of display
|
||||
while ((display.tx < 122) && (myString[strPos] != '\0')) {
|
||||
display.print(myString[strPos]);
|
||||
@ -2305,8 +2307,8 @@ void blinkLED() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void statusLED(boolean on) {
|
||||
#if defined(HW5)
|
||||
void statusLED(boolean on) {
|
||||
if (!on)
|
||||
PORTD |= (1 << 7);
|
||||
else
|
||||
@ -2334,8 +2336,11 @@ void statusLED(boolean on) {
|
||||
PORTB &= ~(1 << 7);
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
void statusLED(boolean on __attribute__ ((unused))) {
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************
|
||||
Menu system
|
||||
|
@ -1803,7 +1803,7 @@ void printFlash(int numBytes) {
|
||||
for (int currByte = 0; currByte < numBytes; currByte += 10) {
|
||||
for (int c = 0; c < 10; c++) {
|
||||
itoa(readByte_Flash(currByte + c), myBuffer, 16);
|
||||
for (int i = 0; i < 2 - strlen(myBuffer); i++) {
|
||||
for (size_t i = 0; i < 2 - strlen(myBuffer); i++) {
|
||||
print_Msg(F("0"));
|
||||
}
|
||||
// Now print the significant bits
|
||||
@ -2147,14 +2147,14 @@ void printFlash16(int numBytes) {
|
||||
|
||||
|
||||
sprintf(buf, "%x", left_byte);
|
||||
for (int i = 0; i < 2 - strlen(buf); i++) {
|
||||
for (size_t i = 0; i < 2 - strlen(buf); i++) {
|
||||
print_Msg(F("0"));
|
||||
}
|
||||
// Now print the significant bits
|
||||
print_Msg(buf);
|
||||
|
||||
sprintf(buf, "%x", right_byte);
|
||||
for (int i = 0; i < 2 - strlen(buf); i++) {
|
||||
for (size_t i = 0; i < 2 - strlen(buf); i++) {
|
||||
print_Msg(F("0"));
|
||||
}
|
||||
// Now print the significant bits
|
||||
@ -2546,14 +2546,14 @@ void print_Eprom(int numBytes) {
|
||||
|
||||
|
||||
sprintf(buf, "%x", left_byte);
|
||||
for (int i = 0; i < 2 - strlen(buf); i++) {
|
||||
for (size_t i = 0; i < 2 - strlen(buf); i++) {
|
||||
print_Msg(F("0"));
|
||||
}
|
||||
// Now print the significant bits
|
||||
print_Msg(buf);
|
||||
|
||||
sprintf(buf, "%x", right_byte);
|
||||
for (int i = 0; i < 2 - strlen(buf); i++) {
|
||||
for (size_t i = 0; i < 2 - strlen(buf); i++) {
|
||||
print_Msg(F("0"));
|
||||
}
|
||||
// Now print the significant bits
|
||||
|
@ -7,8 +7,8 @@
|
||||
Variables
|
||||
*****************************************/
|
||||
// Game Boy
|
||||
int sramBanks;
|
||||
int romBanks;
|
||||
word sramBanks;
|
||||
word romBanks;
|
||||
word lastByte = 0;
|
||||
|
||||
/******************************************
|
||||
@ -911,19 +911,41 @@ void getCartInfo_GB() {
|
||||
}
|
||||
|
||||
// M161 (Mani 4 in 1)
|
||||
if ((strncmp(romName, "TETRIS SET", 10) == 0) && (sdBuffer[0x14D] == 0x3F)) {
|
||||
if (strncmp(romName, "TETRIS SET", 10) == 0 && sdBuffer[0x14D] == 0x3F) {
|
||||
romType = 0x104;
|
||||
}
|
||||
|
||||
// MMM01 (Mani 4 in 1)
|
||||
if (
|
||||
(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, "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
|
||||
)
|
||||
) {
|
||||
romType = 0x0B;
|
||||
}
|
||||
|
||||
// MBC1M
|
||||
if (
|
||||
(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, "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
|
||||
)
|
||||
) {
|
||||
romType += 0x100;
|
||||
}
|
||||
|
||||
@ -961,7 +983,7 @@ void readROM_GB() {
|
||||
print_Error(create_file_STR, true);
|
||||
}
|
||||
|
||||
int endAddress = 0x7FFF;
|
||||
word endAddress = 0x7FFF;
|
||||
word romAddress = 0;
|
||||
word startBank = 1;
|
||||
|
||||
@ -1082,7 +1104,7 @@ void readROM_GB() {
|
||||
}
|
||||
|
||||
// Calculate checksum
|
||||
unsigned int calc_checksum_GB(char* fileName, char* folder) {
|
||||
unsigned int calc_checksum_GB(char* fileName) {
|
||||
unsigned int calcChecksum = 0;
|
||||
// int calcFilesize = 0; // unused
|
||||
unsigned long i = 0;
|
||||
@ -1126,7 +1148,7 @@ void compare_checksums_GB() {
|
||||
|
||||
// Internal ROM checksum
|
||||
char calcsumStr[5];
|
||||
sprintf(calcsumStr, "%04X", calc_checksum_GB(fileName, folder));
|
||||
sprintf(calcsumStr, "%04X", calc_checksum_GB(fileName));
|
||||
|
||||
print_Msg(F("Checksum: "));
|
||||
print_Msg(calcsumStr);
|
||||
@ -1299,6 +1321,7 @@ unsigned long verifySRAM_GB() {
|
||||
return writeErrors;
|
||||
} else {
|
||||
print_Error(open_file_STR, true);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1679,7 +1702,7 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
|
||||
display_Update();
|
||||
|
||||
// Read x number of banks
|
||||
for (int currBank = 0; currBank < romBanks; currBank++) {
|
||||
for (word currBank = 0; currBank < romBanks; currBank++) {
|
||||
// Blink led
|
||||
blinkLED();
|
||||
|
||||
@ -1713,7 +1736,7 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
|
||||
uint32_t totalProgressBar = (uint32_t)(romBanks)*16384;
|
||||
draw_progressbar(0, totalProgressBar);
|
||||
|
||||
for (int currBank = 0; currBank < romBanks; currBank++) {
|
||||
for (word currBank = 0; currBank < romBanks; currBank++) {
|
||||
// Blink led
|
||||
blinkLED();
|
||||
|
||||
@ -1763,7 +1786,7 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
|
||||
uint32_t totalProgressBar = (uint32_t)(romBanks)*16384;
|
||||
draw_progressbar(0, totalProgressBar);
|
||||
|
||||
for (int currBank = 0; currBank < romBanks; currBank++) {
|
||||
for (word currBank = 0; currBank < romBanks; currBank++) {
|
||||
// Blink led
|
||||
blinkLED();
|
||||
|
||||
@ -1885,7 +1908,7 @@ byte readByteCompensated(int address) {
|
||||
.
|
||||
address needs to be the x8 mode address of the flash register that should be read.
|
||||
*/
|
||||
byte writeByteCompensated(int address, byte data) {
|
||||
void writeByteCompensated(int address, byte data) {
|
||||
if (flashSwitchLastBits) {
|
||||
data = (data & 0b11111100) | ((data << 1) & 0b10) | ((data >> 1) & 0b01);
|
||||
}
|
||||
@ -2078,7 +2101,7 @@ bool writeCFI_GB() {
|
||||
display_Update();
|
||||
|
||||
// Read x number of banks
|
||||
for (int currBank = 0; currBank < romBanks; currBank++) {
|
||||
for (word currBank = 0; currBank < romBanks; currBank++) {
|
||||
// Blink led
|
||||
blinkLED();
|
||||
|
||||
@ -2105,7 +2128,7 @@ bool writeCFI_GB() {
|
||||
word currAddr = 0;
|
||||
word endAddr = 0x3FFF;
|
||||
|
||||
for (int currBank = 0; currBank < romBanks; currBank++) {
|
||||
for (word currBank = 0; currBank < romBanks; currBank++) {
|
||||
// Blink led
|
||||
blinkLED();
|
||||
|
||||
|
@ -1339,6 +1339,7 @@ unsigned long verifySRAM_GBA(unsigned long sramSize, uint32_t pos) {
|
||||
return writeErrors;
|
||||
} else {
|
||||
print_Error(F("Can't open file"), false);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1546,6 +1547,7 @@ unsigned long verifyFRAM_GBA(unsigned long framSize) {
|
||||
return writeErrors;
|
||||
} else {
|
||||
print_Error(F("Can't open file"), false);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ void writeByte_GBM(word myAddress, byte myData) {
|
||||
HELPER FUNCTIONS
|
||||
**********************/
|
||||
void printSdBuffer(word startByte, word numBytes) {
|
||||
for (int currByte = 0; currByte < numBytes; currByte += 10) {
|
||||
for (word currByte = 0; currByte < numBytes; currByte += 10) {
|
||||
for (byte c = 0; c < 10; c++) {
|
||||
// Convert to char array so we don't lose leading zeros
|
||||
char currByteStr[2];
|
||||
|
@ -62,7 +62,7 @@ boolean compare_checksum_GBS() {
|
||||
sprintf(folder, "GB/ROM/%s/%d", romName, foldern - 1);
|
||||
|
||||
char calcsumStr[5];
|
||||
sprintf(calcsumStr, "%04X", calc_checksum_GB(fileName, folder));
|
||||
sprintf(calcsumStr, "%04X", calc_checksum_GB(fileName));
|
||||
|
||||
if (strcmp(calcsumStr, checksumStr) == 0) {
|
||||
print_Msg(F("Result: "));
|
||||
@ -404,7 +404,7 @@ void gbSmartReadFlash() {
|
||||
print_Error(create_file_STR, true);
|
||||
|
||||
// reset flash to read array state
|
||||
for (int i = 0x00; i < gbSmartBanks; i += gbSmartBanksPerFlashChip)
|
||||
for (uint16_t i = 0x00; i < gbSmartBanks; i += gbSmartBanksPerFlashChip)
|
||||
gbSmartResetFlash(i);
|
||||
|
||||
// remaps mmc to full access
|
||||
@ -443,7 +443,7 @@ void gbSmartReadFlash() {
|
||||
}
|
||||
|
||||
void gbSmartWriteFlash() {
|
||||
for (int bank = 0x00; bank < gbSmartBanks; bank += gbSmartBanksPerFlashChip) {
|
||||
for (uint16_t bank = 0x00; bank < gbSmartBanks; bank += gbSmartBanksPerFlashChip) {
|
||||
display_Clear();
|
||||
|
||||
print_Msg(F("Erasing..."));
|
||||
|
@ -871,7 +871,7 @@ void setCart_INTV() {
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
|
||||
// Read SRAM size
|
||||
byte sramSize = myFile.read() - 48;
|
||||
byte sramSize __attribute__ ((unused)) = myFile.read() - 48;
|
||||
|
||||
// Skip rest of line
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
|
@ -8,7 +8,7 @@
|
||||
Variables
|
||||
*****************************************/
|
||||
unsigned long sramEnd;
|
||||
int eepSize;
|
||||
word eepSize;
|
||||
word addrhi;
|
||||
word addrlo;
|
||||
word chksum;
|
||||
@ -1176,10 +1176,10 @@ void readROM_MD() {
|
||||
byte buffer[1024] = { 0 };
|
||||
|
||||
// get current time
|
||||
unsigned long startTime = millis();
|
||||
// unsigned long startTime = millis();
|
||||
|
||||
// Phantasy Star/Beyond Oasis with 74HC74 and 74HC139 switch ROM/SRAM at address 0x200000
|
||||
if (0x200000 < cartSize < 0x400000) {
|
||||
if (0x200000 < cartSize && cartSize < 0x400000) {
|
||||
enableSram_MD(0);
|
||||
}
|
||||
|
||||
@ -1561,7 +1561,7 @@ void readSram_MD() {
|
||||
}
|
||||
unsigned long padsize = (1UL << 16) - (sramSize << 1);
|
||||
unsigned long padblockcount = padsize >> 9; // number of 512 byte blocks
|
||||
for (int i = 0; i < padblockcount; i++) {
|
||||
for (unsigned long i = 0; i < padblockcount; i++) {
|
||||
myFile.write(sdBuffer, 512);
|
||||
}
|
||||
}
|
||||
|
@ -981,7 +981,6 @@ void controllerTest_Display() {
|
||||
// Graph
|
||||
int xax = 24; // midpoint x
|
||||
int yax = 24; // midpoint y
|
||||
int zax = 24; // size
|
||||
|
||||
// variables to display test data of different sticks
|
||||
int upx = 0;
|
||||
@ -1727,20 +1726,16 @@ void verifyCRC() {
|
||||
}
|
||||
|
||||
// Calculates the checksum of the header
|
||||
boolean checkHeader(byte startAddress) {
|
||||
boolean checkHeader(byte *buf) {
|
||||
word sum = 0;
|
||||
word buf_sum = (buf[28] << 8) + buf[29];
|
||||
|
||||
// first 28 bytes are the header, then comes the checksum(word) followed by the reverse checksum(0xFFF2 - checksum)
|
||||
for (int i = 0; i < 28; i += 2) {
|
||||
word tempword = (((sdBuffer[startAddress + i] & 0xFF) << 8) | (sdBuffer[startAddress + i + 1] & 0xFF));
|
||||
sum += tempword;
|
||||
for (byte i = 0; i < 28; i += 2) {
|
||||
sum += (buf[i] << 8) + buf[i + 1];
|
||||
}
|
||||
|
||||
if ((((sdBuffer[startAddress + 28] & 0xFF) << 8) | (sdBuffer[startAddress + 29] & 0xFF)) != (sum & 0xFFFF)) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
return sum == buf_sum;
|
||||
}
|
||||
|
||||
// verifies if Controller Pak holds valid header data
|
||||
@ -1755,13 +1750,13 @@ void validateMPK() {
|
||||
|
||||
//Check all four header copies
|
||||
writeErrors = 0;
|
||||
if (!checkHeader(0x20))
|
||||
if (!checkHeader(&sdBuffer[0x20]))
|
||||
writeErrors++;
|
||||
if (!checkHeader(0x60))
|
||||
if (!checkHeader(&sdBuffer[0x60]))
|
||||
writeErrors++;
|
||||
if (!checkHeader(0x80))
|
||||
if (!checkHeader(&sdBuffer[0x80]))
|
||||
writeErrors++;
|
||||
if (!checkHeader(0xC0))
|
||||
if (!checkHeader(&sdBuffer[0xC0]))
|
||||
writeErrors++;
|
||||
|
||||
print_Msg(F("HDR: "));
|
||||
@ -2484,6 +2479,7 @@ unsigned long verifyEeprom_CLK() {
|
||||
return writeErrors;
|
||||
} else {
|
||||
print_Error(F("Savetype Error"), true);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2850,6 +2846,7 @@ unsigned long verifyEeprom() {
|
||||
return writeErrors;
|
||||
} else {
|
||||
print_Error(F("Savetype Error"), true);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3630,8 +3627,8 @@ void savesummary_N64(boolean checkfound, char crcStr[9], unsigned long timeElaps
|
||||
N64 Repro Flashrom Functions
|
||||
*****************************************/
|
||||
void flashRepro_N64() {
|
||||
unsigned long sectorSize;
|
||||
byte bufferSize;
|
||||
unsigned long sectorSize = 0;
|
||||
byte bufferSize = 0;
|
||||
// Check flashrom ID's
|
||||
idFlashrom_N64();
|
||||
|
||||
@ -3870,10 +3867,14 @@ void flashRepro_N64() {
|
||||
// Intel 4400L0ZDQ0
|
||||
writeIntel4400_N64();
|
||||
resetIntel4400_N64();
|
||||
} else if (bufferSize == 0) {
|
||||
writeFlashrom_N64(sectorSize);
|
||||
} else if (sectorSize) {
|
||||
if (bufferSize) {
|
||||
writeFlashBuffer_N64(sectorSize, bufferSize);
|
||||
} else {
|
||||
writeFlashrom_N64(sectorSize);
|
||||
}
|
||||
} else {
|
||||
writeFlashBuffer_N64(sectorSize, bufferSize);
|
||||
print_Error(F("sectorSize not set"), true);
|
||||
}
|
||||
|
||||
// Close the file:
|
||||
@ -4498,7 +4499,7 @@ void writeFlashBuffer_N64(unsigned long sectorSize, byte bufferSize) {
|
||||
writeWord_N64((bufferSize / 2) - 1);
|
||||
|
||||
// Define variable before loop so we can use it later when reading the status register
|
||||
word currWord;
|
||||
word currWord = 0;
|
||||
|
||||
for (byte currByte = 0; currByte < bufferSize; currByte += 2) {
|
||||
// Join two bytes into one word
|
||||
|
@ -186,7 +186,7 @@ byte prgchk1;
|
||||
boolean mmc6 = false;
|
||||
byte prgchk2;
|
||||
byte prgchk3;
|
||||
int eepsize;
|
||||
word eepsize;
|
||||
byte bytecheck;
|
||||
byte firstbyte;
|
||||
boolean flashfound = false; // NESmaker 39SF040 Flash Cart
|
||||
@ -206,7 +206,6 @@ char fileBIN[] = "CART.bin";
|
||||
|
||||
// Cartridge Config
|
||||
byte mapper;
|
||||
byte newmapper;
|
||||
byte prgsize;
|
||||
byte newprgsize;
|
||||
byte chrsize;
|
||||
@ -632,10 +631,10 @@ boolean getMapping() {
|
||||
skip_line(&myFile);
|
||||
|
||||
// Convert "4E4553" to (0x4E, 0x45, 0x53)
|
||||
byte iNES_BUF[2];
|
||||
unsigned int iNES_BUF;
|
||||
for (byte j = 0; j < 16; j++) {
|
||||
sscanf(iNES_STR + j * 2, "%2X", iNES_BUF);
|
||||
iNES_HEADER[j] = iNES_BUF[0];
|
||||
sscanf(iNES_STR + j * 2, "%2X", &iNES_BUF);
|
||||
iNES_HEADER[j] = iNES_BUF;
|
||||
}
|
||||
|
||||
// Convert iNES garbage to useful info (thx to fceux)
|
||||
@ -925,10 +924,10 @@ void selectMapping() {
|
||||
skip_line(&myFile);
|
||||
|
||||
// Convert "4E4553" to (0x4E, 0x45, 0x53)
|
||||
byte iNES_BUF[2];
|
||||
unsigned int iNES_BUF;
|
||||
for (byte j = 0; j < 16; j++) {
|
||||
sscanf(iNES_STR + j * 2, "%2X", iNES_BUF);
|
||||
iNES_HEADER[j] = iNES_BUF[0];
|
||||
sscanf(iNES_STR + j * 2, "%2X", &iNES_BUF);
|
||||
iNES_HEADER[j] = iNES_BUF;
|
||||
}
|
||||
|
||||
// Convert iNES garbage to useful info (thx to fceux)
|
||||
@ -1212,17 +1211,6 @@ void readRaw_NES() {
|
||||
/******************************************
|
||||
Low Level Functions
|
||||
*****************************************/
|
||||
static void phi2_init() {
|
||||
int i = 0x80;
|
||||
unsigned char h = PORTF |= (1 << 0);
|
||||
unsigned char l = PORTF &= ~(1 << 0);
|
||||
while (i != 0) {
|
||||
PORTL = l;
|
||||
PORTL = h;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
static void set_address(unsigned int address) {
|
||||
unsigned char l = address & 0xFF;
|
||||
unsigned char h = address >> 8;
|
||||
@ -1295,60 +1283,6 @@ static void write_prg_byte(unsigned int address, uint8_t data) {
|
||||
// _delay_us(1);
|
||||
}
|
||||
|
||||
static void write_chr_byte(unsigned int address, uint8_t data) {
|
||||
PHI2_LOW;
|
||||
ROMSEL_HI;
|
||||
MODE_WRITE;
|
||||
PORTK = data;
|
||||
|
||||
set_address(address); // PHI2 low, ROMSEL always HIGH
|
||||
//_delay_us(10);
|
||||
CHR_WRITE_LOW;
|
||||
_delay_us(1); // WRITING
|
||||
//_delay_ms(1); // WRITING
|
||||
CHR_WRITE_HI;
|
||||
//_delay_us(1);
|
||||
MODE_READ;
|
||||
set_address(0);
|
||||
PHI2_HI;
|
||||
//_delay_us(1);
|
||||
}
|
||||
|
||||
static void write_prg(unsigned int address, unsigned int len, uint8_t* data) {
|
||||
LED_RED_ON;
|
||||
while (len > 0) {
|
||||
write_prg_byte(address, *data);
|
||||
address++;
|
||||
len--;
|
||||
data++;
|
||||
}
|
||||
//_delay_ms(1);
|
||||
LED_RED_OFF;
|
||||
}
|
||||
|
||||
static void write_chr(unsigned int address, unsigned int len, uint8_t* data) {
|
||||
LED_RED_ON;
|
||||
while (len > 0) {
|
||||
write_chr_byte(address, *data);
|
||||
address++;
|
||||
len--;
|
||||
data++;
|
||||
}
|
||||
//_delay_ms(1);
|
||||
LED_RED_OFF;
|
||||
}
|
||||
|
||||
static void reset_phi2() {
|
||||
LED_RED_ON;
|
||||
LED_GREEN_ON;
|
||||
PHI2_LOW;
|
||||
ROMSEL_HI;
|
||||
_delay_ms(100);
|
||||
PHI2_HI;
|
||||
LED_RED_OFF;
|
||||
LED_GREEN_OFF;
|
||||
}
|
||||
|
||||
void resetROM() {
|
||||
set_address(0);
|
||||
PHI2_HI;
|
||||
@ -2017,6 +1951,7 @@ unsigned char* getNES20HeaderBytesFromDatabaseRow(const char* crctest) {
|
||||
Config Functions
|
||||
*****************************************/
|
||||
void setMapper() {
|
||||
byte newmapper;
|
||||
#ifdef global_log
|
||||
// Disable log to prevent unnecessary logging
|
||||
println_Log(F("Set Mapper manually"));
|
||||
@ -2028,7 +1963,7 @@ void setMapper() {
|
||||
chooseMapper:
|
||||
// Read stored mapper
|
||||
EEPROM_readAnything(7, newmapper);
|
||||
if ((newmapper > 220) || (newmapper < 0))
|
||||
if (newmapper > 220)
|
||||
newmapper = 0;
|
||||
// Split into digits
|
||||
byte hundreds = newmapper / 100;
|
||||
@ -2920,7 +2855,7 @@ void readPRG(boolean readrom) {
|
||||
case 87: // 16K/32K
|
||||
case 184: // 32K
|
||||
case 185: // 16K/32K
|
||||
for (word address = 0; address < ((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);
|
||||
}
|
||||
break;
|
||||
@ -2948,7 +2883,7 @@ void readPRG(boolean readrom) {
|
||||
case 2: // 128K/256K
|
||||
for (int i = 0; i < 8; i++) { // 128K/256K
|
||||
write_prg_byte(0x8000, i);
|
||||
for (word address = 0x0; address < (((prgsize - 3) * 0x4000) + 0x4000); address += 512) {
|
||||
for (word address = 0x0; address < (((word) prgsize - 3) * 0x4000) + 0x4000; address += 512) {
|
||||
dumpPRG(base, address);
|
||||
}
|
||||
}
|
||||
@ -5113,11 +5048,11 @@ void writeFLASH() {
|
||||
myFile.read(sdBuffer, 512);
|
||||
for (int x = 0; x < 512; x++) {
|
||||
word location = base + sector + addr + x;
|
||||
NESmaker_ByteProgram(i, base + sector + addr + x, sdBuffer[x]);
|
||||
NESmaker_ByteProgram(i, location, sdBuffer[x]);
|
||||
delayMicroseconds(14); // Typical 14us
|
||||
for (byte k = 0; k < 2; k++) { // Confirm write twice
|
||||
do {
|
||||
bytecheck = read_prg_byte(base + sector + addr + x);
|
||||
bytecheck = read_prg_byte(location);
|
||||
delayMicroseconds(14);
|
||||
} while (bytecheck != sdBuffer[x]);
|
||||
}
|
||||
@ -5152,6 +5087,11 @@ void writeFLASH() {
|
||||
sd.chdir(); // root
|
||||
filePath[0] = '\0'; // Reset filePath
|
||||
}
|
||||
|
||||
// avoid warnings
|
||||
#undef MODE_READ
|
||||
#undef MODE_WRITE
|
||||
|
||||
#endif
|
||||
//******************************************
|
||||
// End of File
|
||||
|
@ -248,7 +248,6 @@ void readROM_NGP(char* outPathBuf, size_t bufferSize) {
|
||||
|
||||
void scanChip_NGP() {
|
||||
display_Clear();
|
||||
uint32_t block_addr = 0;
|
||||
|
||||
// generate name of report file
|
||||
snprintf(fileName, FILENAME_LENGTH, "%s.txt", romName);
|
||||
|
@ -440,9 +440,8 @@ uint32_t calculate_crc32(int n, unsigned char c[], uint32_t r) {
|
||||
return r;
|
||||
}
|
||||
|
||||
void crc_search(char *file_p, char *folder_p, uint32_t rom_size, uint32_t crc) {
|
||||
void crc_search(char *file_p, char *folder_p, uint32_t rom_size __attribute__ ((unused)), uint32_t crc) {
|
||||
FsFile rom, script;
|
||||
uint32_t r, processedsize;
|
||||
char gamename[100];
|
||||
char crc_file[9], crc_search[9];
|
||||
uint8_t flag;
|
||||
@ -519,10 +518,6 @@ void lock_tennokoe_bank_RAM() {
|
||||
}
|
||||
|
||||
void read_tennokoe_bank_PCE(int bank_index) {
|
||||
uint32_t processed_size = 0;
|
||||
uint32_t verify_loop;
|
||||
uint8_t verify_flag = 1;
|
||||
|
||||
//clear the screen
|
||||
display_Clear();
|
||||
|
||||
|
@ -657,6 +657,11 @@ unsigned long verifySRAM_PCW() {
|
||||
|
||||
return writeErrors;
|
||||
}
|
||||
|
||||
// avoid warnings
|
||||
#undef MODE_READ
|
||||
#undef MODE_WRITE
|
||||
|
||||
#endif
|
||||
//******************************************
|
||||
// End of File
|
||||
|
@ -941,7 +941,7 @@ void readROM_SFM() {
|
||||
display_Update();
|
||||
|
||||
// Read up to 96 banks starting at bank 0×00.
|
||||
for (int currBank = 0; currBank < numBanks; currBank++) {
|
||||
for (byte currBank = 0; currBank < numBanks; currBank++) {
|
||||
// Dump the bytes to SD 512B at a time
|
||||
for (long currByte = 32768; currByte < 65536; currByte += 512) {
|
||||
for (int c = 0; c < 512; c++) {
|
||||
@ -956,7 +956,7 @@ void readROM_SFM() {
|
||||
println_Msg(F("Dumping HiRom..."));
|
||||
display_Update();
|
||||
|
||||
for (int currBank = 192; currBank < (numBanks + 192); currBank++) {
|
||||
for (byte currBank = 192; currBank < (numBanks + 192); currBank++) {
|
||||
for (long currByte = 0; currByte < 65536; currByte += 512) {
|
||||
for (int c = 0; c < 512; c++) {
|
||||
sdBuffer[c] = readBank_SFM(currBank, currByte + c);
|
||||
@ -1056,7 +1056,7 @@ void writeFlash_SFM(int startBank, uint32_t pos) {
|
||||
|
||||
if (romType) {
|
||||
// Write hirom
|
||||
for (int currBank = startBank; currBank < startBank + numBanks; currBank++) {
|
||||
for (byte currBank = startBank; currBank < startBank + numBanks; currBank++) {
|
||||
// Fill SDBuffer with 1 page at a time then write it repeat until all bytes are written
|
||||
for (unsigned long currByte = 0; currByte < 0x10000; currByte += 128) {
|
||||
myFile.read(sdBuffer, 128);
|
||||
@ -1081,7 +1081,7 @@ void writeFlash_SFM(int startBank, uint32_t pos) {
|
||||
}
|
||||
} else {
|
||||
// Write lorom
|
||||
for (int currBank = 0; currBank < numBanks; currBank++) {
|
||||
for (byte currBank = 0; currBank < numBanks; currBank++) {
|
||||
for (unsigned long currByte = 0x8000; currByte < 0x10000; currByte += 128) {
|
||||
myFile.read(sdBuffer, 128);
|
||||
// Write command sequence
|
||||
@ -1184,7 +1184,7 @@ byte blankcheck_SFM(int startBank) {
|
||||
|
||||
byte blank = 1;
|
||||
if (romType) {
|
||||
for (int currBank = startBank; currBank < startBank + numBanks; currBank++) {
|
||||
for (byte currBank = startBank; currBank < startBank + numBanks; currBank++) {
|
||||
for (unsigned long currByte = 0; currByte < 0x10000; currByte++) {
|
||||
if (readBank_SFM(currBank, currByte) != 0xFF) {
|
||||
currBank = startBank + numBanks;
|
||||
@ -1193,7 +1193,7 @@ byte blankcheck_SFM(int startBank) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int currBank = 0; currBank < numBanks; currBank++) {
|
||||
for (byte currBank = 0; currBank < numBanks; currBank++) {
|
||||
for (unsigned long currByte = 0x8000; currByte < 0x10000; currByte++) {
|
||||
if (readBank_SFM(currBank, currByte) != 0xFF) {
|
||||
currBank = numBanks;
|
||||
@ -1221,7 +1221,7 @@ unsigned long verifyFlash_SFM(int startBank, uint32_t pos) {
|
||||
controlIn_SFM();
|
||||
|
||||
if (romType) {
|
||||
for (int currBank = startBank; currBank < startBank + numBanks; currBank++) {
|
||||
for (byte currBank = startBank; currBank < startBank + numBanks; currBank++) {
|
||||
for (unsigned long currByte = 0; currByte < 0x10000; currByte += 512) {
|
||||
// Fill SDBuffer
|
||||
myFile.read(sdBuffer, 512);
|
||||
@ -1233,7 +1233,7 @@ unsigned long verifyFlash_SFM(int startBank, uint32_t pos) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int currBank = 0; currBank < numBanks; currBank++) {
|
||||
for (byte currBank = 0; currBank < numBanks; currBank++) {
|
||||
for (unsigned long currByte = 0x8000; currByte < 0x10000; currByte += 512) {
|
||||
// Fill SDBuffer
|
||||
myFile.read(sdBuffer, 512);
|
||||
@ -1273,7 +1273,7 @@ void readFlash_SFM() {
|
||||
print_Error(create_file_STR, true);
|
||||
}
|
||||
if (romType) {
|
||||
for (int currBank = 0xC0; currBank < 0xC0 + numBanks; currBank++) {
|
||||
for (byte currBank = 0xC0; currBank < 0xC0 + numBanks; currBank++) {
|
||||
for (unsigned long currByte = 0; currByte < 0x10000; currByte += 512) {
|
||||
for (int c = 0; c < 512; c++) {
|
||||
sdBuffer[c] = readBank_SFM(currBank, currByte + c);
|
||||
@ -1282,7 +1282,7 @@ void readFlash_SFM() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int currBank = 0; currBank < numBanks; currBank++) {
|
||||
for (byte currBank = 0; currBank < numBanks; currBank++) {
|
||||
for (unsigned long currByte = 0x8000; currByte < 0x10000; currByte += 512) {
|
||||
for (int c = 0; c < 512; c++) {
|
||||
sdBuffer[c] = readBank_SFM(currBank, currByte + c);
|
||||
@ -1348,10 +1348,10 @@ void printMapping() {
|
||||
// Read the mapping out of the first chip
|
||||
char buffer[3];
|
||||
|
||||
for (int currByte = 0xFF00; currByte < 0xFF50; currByte += 10) {
|
||||
for (unsigned int currByte = 0xFF00; currByte < 0xFF50; currByte += 10) {
|
||||
for (int c = 0; c < 10; c++) {
|
||||
itoa(readBank_SFM(0xC0, currByte + c), buffer, 16);
|
||||
for (int i = 0; i < 2 - strlen(buffer); i++) {
|
||||
for (size_t i = 0; i < 2 - strlen(buffer); i++) {
|
||||
print_Msg(F("0"));
|
||||
}
|
||||
// Now print the significant bits
|
||||
|
@ -204,8 +204,6 @@ void snesMenu() {
|
||||
display_Clear();
|
||||
// Change working dir to root
|
||||
sd.chdir("/");
|
||||
// get current time
|
||||
unsigned long startTime = millis();
|
||||
// start reading from cart
|
||||
readROM_SNES();
|
||||
// Internal Checksum
|
||||
@ -604,7 +602,7 @@ void readLoRomBanks(unsigned int start, unsigned int total, FsFile* file) {
|
||||
uint32_t totalProgressBar = (uint32_t)(total - start) * 1024;
|
||||
draw_progressbar(0, totalProgressBar);
|
||||
|
||||
for (int currBank = start; currBank < total; currBank++) {
|
||||
for (byte currBank = start; currBank < total; currBank++) {
|
||||
PORTL = currBank;
|
||||
|
||||
// Blink led
|
||||
@ -655,7 +653,7 @@ void readHiRomBanks(unsigned int start, unsigned int total, FsFile* file) {
|
||||
uint32_t totalProgressBar = (uint32_t)(total - start) * 1024;
|
||||
draw_progressbar(0, totalProgressBar);
|
||||
|
||||
for (int currBank = start; currBank < total; currBank++) {
|
||||
for (byte currBank = start; currBank < total; currBank++) {
|
||||
PORTL = currBank;
|
||||
|
||||
// Blink led
|
||||
@ -701,31 +699,6 @@ void readHiRomBanks(unsigned int start, unsigned int total, FsFile* file) {
|
||||
void getCartInfo_SNES() {
|
||||
boolean manualConfig = 0;
|
||||
|
||||
//Prime SA1 cartridge
|
||||
uint16_t c = 0;
|
||||
uint16_t currByte = 0;
|
||||
byte buffer[1024] = { 0 };
|
||||
PORTL = 192;
|
||||
while (c < 1024) {
|
||||
PORTF = (currByte & 0xFF);
|
||||
PORTK = ((currByte >> 8) & 0xFF);
|
||||
|
||||
// Wait for the Byte to appear on the data bus
|
||||
// Arduino running at 16Mhz -> one nop = 62.5ns
|
||||
// slowRom is good for 200ns, fastRom is <= 120ns; S-CPU best case read speed: 3.57MHz / 280ns
|
||||
// let's be conservative and use 6 x 62.5 = 375ns
|
||||
NOP;
|
||||
NOP;
|
||||
NOP;
|
||||
NOP;
|
||||
NOP;
|
||||
NOP;
|
||||
|
||||
buffer[c] = PINC;
|
||||
c++;
|
||||
currByte++;
|
||||
}
|
||||
|
||||
// Print start page
|
||||
if (checkcart_SNES() == 0) {
|
||||
// Checksum either corrupt or 0000
|
||||
@ -953,12 +926,10 @@ boolean checkcart_SNES() {
|
||||
// set control to read
|
||||
dataIn();
|
||||
|
||||
uint16_t c = 0;
|
||||
uint16_t headerStart = 0xFFB0;
|
||||
uint16_t currByte = headerStart;
|
||||
byte snesHeader[80] = { 0 };
|
||||
byte snesHeader[80];
|
||||
PORTL = 0;
|
||||
while (c < 80) {
|
||||
for (uint16_t c = 0, currByte = headerStart; c < 80; c++, currByte++) {
|
||||
PORTF = (currByte & 0xFF);
|
||||
PORTK = ((currByte >> 8) & 0xFF);
|
||||
|
||||
@ -976,8 +947,6 @@ boolean checkcart_SNES() {
|
||||
NOP;
|
||||
|
||||
snesHeader[c] = PINC;
|
||||
c++;
|
||||
currByte++;
|
||||
}
|
||||
|
||||
// Calculate CRC32 of header
|
||||
@ -1396,7 +1365,7 @@ void readROM_SNES() {
|
||||
controlIn_SNES();
|
||||
byte initialSOMap = readBank_SNES(0, 18439);
|
||||
|
||||
for (int currMemmap = 0; currMemmap < (numBanks / 16); currMemmap++) {
|
||||
for (byte currMemmap = 0; currMemmap < (numBanks / 16); currMemmap++) {
|
||||
|
||||
dataOut();
|
||||
controlOut_SNES();
|
||||
@ -1974,6 +1943,7 @@ unsigned long verifySRAM() {
|
||||
return writeErrors;
|
||||
} else {
|
||||
print_Error(F("Can't open file"), false);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,11 +302,8 @@ void readSRAM_SV() {
|
||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||
print_Error(sd_error_STR, true);
|
||||
}
|
||||
int sramBanks = 0;
|
||||
|
||||
readBank_SV(0x10, 0); // Preconfigure to fix corrupt 1st byte
|
||||
// Sram size
|
||||
long lastByte = (long(sramSize) * 0x80);
|
||||
|
||||
//startBank = 0x10; endBank = 0x17; CS low
|
||||
for (byte BSBank = 0x10; BSBank < 0x18; BSBank++) {
|
||||
@ -347,8 +344,6 @@ void writeSRAM_SV() {
|
||||
// Set RST RD WR to High and CS to Low
|
||||
controlOut_SNES();
|
||||
|
||||
long lastByte = (long(sramSize) * 0x80);
|
||||
|
||||
println_Msg(F("Writing sram..."));
|
||||
display_Update();
|
||||
|
||||
@ -390,10 +385,6 @@ unsigned long verifySRAM_SV() {
|
||||
// Set control
|
||||
controlIn_SNES();
|
||||
|
||||
int sramBanks = 0;
|
||||
// Sram size
|
||||
long lastByte = (long(sramSize) * 0x80);
|
||||
|
||||
//startBank = 0x10; endBank = 0x17; CS low
|
||||
for (byte BSBank = 0x10; BSBank < 0x18; BSBank++) {
|
||||
//startAddr = 0x5000
|
||||
@ -412,6 +403,7 @@ unsigned long verifySRAM_SV() {
|
||||
return writeErrors;
|
||||
} else {
|
||||
print_Error(F("Can't open file"), false);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -981,7 +981,7 @@ boolean compareChecksum_WS(const char *wsFilePath) {
|
||||
}
|
||||
|
||||
uint32_t calLength = myFile.fileSize() - 512;
|
||||
uint32_t checksum = 0;
|
||||
uint16_t checksum = 0;
|
||||
|
||||
if (wsWitch) {
|
||||
// only calcuate last 128Kbytes for wonderwitch (OS and BIOS region)
|
||||
@ -1003,18 +1003,12 @@ boolean compareChecksum_WS(const char *wsFilePath) {
|
||||
|
||||
myFile.close();
|
||||
|
||||
checksum &= 0x0000ffff;
|
||||
calLength = wsGameChecksum;
|
||||
|
||||
// don't know why formating string "%04X(%04X)" always output "xxxx(0000)"
|
||||
// so split into two snprintf
|
||||
char result[11];
|
||||
snprintf(result, 5, "%04X", calLength);
|
||||
snprintf(result + 4, 11 - 4, "(%04X)", checksum);
|
||||
snprintf(result, 11, "%04X(%04X)", wsGameChecksum, checksum);
|
||||
print_Msg(F("Result: "));
|
||||
println_Msg(result);
|
||||
|
||||
if (checksum == calLength) {
|
||||
if (checksum == wsGameChecksum) {
|
||||
println_Msg(F("Checksum matches"));
|
||||
display_Update();
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user