mirror of
https://github.com/sanni/cartreader.git
synced 2025-02-17 05:26:20 +01:00
add common function to open create folder, print message and open file. Remove duplicate code
This commit is contained in:
parent
78bf1462d0
commit
363d18b542
@ -296,13 +296,7 @@ boolean checkE7(uint16_t bank) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void readROM_2600() {
|
void readROM_2600() {
|
||||||
createFolder("ATARI", "ROM", romName, "a26");
|
createFolderAndOpenFile("ATARI", "ROM", romName, "a26");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// open file on sdcard
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
|
|
||||||
// ROM Start 0xF000
|
// ROM Start 0xF000
|
||||||
// Address A12-A0 = 0x1000 = 1 0000 0000 0000 = 4KB
|
// Address A12-A0 = 0x1000 = 1 0000 0000 0000 = 4KB
|
||||||
|
@ -216,16 +216,9 @@ void readSegment_5200(uint16_t startaddr, uint16_t endaddr) {
|
|||||||
//******************************************
|
//******************************************
|
||||||
|
|
||||||
void readROM_5200() {
|
void readROM_5200() {
|
||||||
createFolder("5200", "ROM", romName, "a52");
|
createFolderAndOpenFile("5200", "ROM", romName, "a52");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// open file on sdcard
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
|
|
||||||
// 5200 A13-A0 = 10 0000 0000 0000
|
// 5200 A13-A0 = 10 0000 0000 0000
|
||||||
|
|
||||||
switch (a5200mapper) {
|
switch (a5200mapper) {
|
||||||
case 0: // Standard 4KB/8KB/16KB/32KB
|
case 0: // Standard 4KB/8KB/16KB/32KB
|
||||||
// Lower Half of 32K is at 0x4000
|
// Lower Half of 32K is at 0x4000
|
||||||
|
@ -342,13 +342,7 @@ void bankSwitch_7800(uint16_t addr) {
|
|||||||
//******************************************
|
//******************************************
|
||||||
|
|
||||||
void readROM_7800() {
|
void readROM_7800() {
|
||||||
createFolder("7800", "ROM", romName, "a78");
|
createFolderAndOpenFile("7800", "ROM", romName, "a78");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// open file on sdcard
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
|
|
||||||
switch (a7800mapper) {
|
switch (a7800mapper) {
|
||||||
case 0: // Standard 16K/32K/48K [7816/7832/7848]
|
case 0: // Standard 16K/32K/48K [7816/7832/7848]
|
||||||
|
@ -150,14 +150,7 @@ void readSegment_ARC(uint16_t startaddr, uint16_t endaddr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void readROM_ARC() {
|
void readROM_ARC() {
|
||||||
createFolder("ARC", "ROM", romName, "bin");
|
createFolderAndOpenFile("ARC", "ROM", romName, "bin");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// open file on sdcard
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
readSegment_ARC(0x0000, 0x0800); // 2K
|
readSegment_ARC(0x0000, 0x0800); // 2K
|
||||||
if (arcsize > 0) {
|
if (arcsize > 0) {
|
||||||
|
@ -364,13 +364,7 @@ void readPorts_C64() {
|
|||||||
// GAME HIGH/EXROM LOW: ROML = $8000
|
// GAME HIGH/EXROM LOW: ROML = $8000
|
||||||
|
|
||||||
void readROM_C64() {
|
void readROM_C64() {
|
||||||
createFolder("C64", "ROM", romName, "bin");
|
createFolderAndOpenFile("C64", "ROM", romName, "bin");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// open file on sdcard
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
|
|
||||||
switch (c64mapper) {
|
switch (c64mapper) {
|
||||||
case 0: // Normal (4K/8K/16K) & Ultimax (8K/16K)
|
case 0: // Normal (4K/8K/16K) & Ultimax (8K/16K)
|
||||||
|
@ -162,13 +162,7 @@ void readSegment_COL(uint32_t startaddr, uint32_t endaddr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void readROM_COL() {
|
void readROM_COL() {
|
||||||
createFolder("COL", "ROM", romName, "col");
|
createFolderAndOpenFile("COL", "ROM", romName, "col");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// open file on sdcard
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
|
|
||||||
// RESET ALL CS PINS HIGH (DISABLE)
|
// RESET ALL CS PINS HIGH (DISABLE)
|
||||||
PORTH |= (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
|
PORTH |= (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
|
||||||
|
@ -692,6 +692,15 @@ void printAndIncrementFolder(bool displayClear = false) {
|
|||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(0, foldern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void createFolderAndOpenFile(const char* system, const char* subfolder, const char* gameName, const char* fileSuffix) {
|
||||||
|
createFolder(system, subfolder, gameName, fileSuffix);
|
||||||
|
printAndIncrementFolder(true);
|
||||||
|
|
||||||
|
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||||
|
print_FatalError(sd_error_STR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// move file pointer to first game line with matching letter. If no match is found the last database entry is selected
|
// move file pointer to first game line with matching letter. If no match is found the last database entry is selected
|
||||||
void seek_first_letter_in_database(FsFile& database, byte myLetter) {
|
void seek_first_letter_in_database(FsFile& database, byte myLetter) {
|
||||||
char gamename_str[3];
|
char gamename_str[3];
|
||||||
|
@ -392,14 +392,7 @@ uint8_t readData_FAIRCHILD() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void readROM_FAIRCHILD() {
|
void readROM_FAIRCHILD() {
|
||||||
createFolder("FAIRCHILD", "ROM", romName, "bin");
|
createFolderAndOpenFile("FAIRCHILD", "ROM", romName, "bin");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// open file on sdcard
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long cartsize = FAIRCHILD[fairchildsize] * 0x400;
|
unsigned long cartsize = FAIRCHILD[fairchildsize] * 0x400;
|
||||||
uint8_t blocks = cartsize / 0x200;
|
uint8_t blocks = cartsize / 0x200;
|
||||||
|
@ -1107,14 +1107,7 @@ void getCartInfo_GB() {
|
|||||||
// Read ROM
|
// Read ROM
|
||||||
void readROM_GB() {
|
void readROM_GB() {
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
createFolder("GB", "ROM", romName, "gb");
|
createFolderAndOpenFile("GB", "ROM", romName, "gb");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
//open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
word endAddress = 0x7FFF;
|
word endAddress = 0x7FFF;
|
||||||
word romAddress = 0;
|
word romAddress = 0;
|
||||||
@ -1454,14 +1447,7 @@ unsigned long verifySRAM_GB() {
|
|||||||
// Read SRAM + FLASH save data of MBC6
|
// Read SRAM + FLASH save data of MBC6
|
||||||
void readSRAMFLASH_MBC6_GB() {
|
void readSRAMFLASH_MBC6_GB() {
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
createFolder("GB", "SAVE", romName, "sav");
|
createFolderAndOpenFile("GB", "SAVE", romName, "sav");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
//open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Initialize progress bar
|
//Initialize progress bar
|
||||||
uint32_t processedProgressBar = 0;
|
uint32_t processedProgressBar = 0;
|
||||||
@ -2524,14 +2510,7 @@ bool writeCFI_GB() {
|
|||||||
// Read Pelican GBC Device - All Brainboys, MonsterBrains, Codebreakers
|
// Read Pelican GBC Device - All Brainboys, MonsterBrains, Codebreakers
|
||||||
void readPelican_GB() {
|
void readPelican_GB() {
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
createFolder("GB", "ROM", "Pelican", "GB");
|
createFolderAndOpenFile("GB", "ROM", "Pelican", "GB");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
//open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
word finalAddress = 0x3FFF;
|
word finalAddress = 0x3FFF;
|
||||||
word startAddress = 0x2000;
|
word startAddress = 0x2000;
|
||||||
|
@ -821,14 +821,7 @@ void getCartInfo_GBA() {
|
|||||||
// Dump ROM
|
// Dump ROM
|
||||||
void readROM_GBA() {
|
void readROM_GBA() {
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
createFolder("GBA", "ROM", romName, "gba");
|
createFolderAndOpenFile("GBA", "ROM", romName, "gba");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
//open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Initialize progress bar
|
//Initialize progress bar
|
||||||
uint32_t processedProgressBar = 0;
|
uint32_t processedProgressBar = 0;
|
||||||
@ -1045,14 +1038,8 @@ void readFRAM_GBA(unsigned long framSize) {
|
|||||||
PORTH &= ~((1 << 0) | (1 << 6));
|
PORTH &= ~((1 << 0) | (1 << 6));
|
||||||
|
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
createFolder("GBA", "SAVE", romName, "srm");
|
createFolderAndOpenFile("GBA", "SAVE", romName, "srm");
|
||||||
|
|
||||||
printAndIncrementFolder();
|
|
||||||
|
|
||||||
//open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
}
|
|
||||||
for (unsigned long currAddress = 0; currAddress < framSize; currAddress += 512) {
|
for (unsigned long currAddress = 0; currAddress < framSize; currAddress += 512) {
|
||||||
for (int c = 0; c < 512; c++) {
|
for (int c = 0; c < 512; c++) {
|
||||||
// Pull OE_SRAM(PH6) HIGH
|
// Pull OE_SRAM(PH6) HIGH
|
||||||
|
@ -268,15 +268,7 @@ void readRAM_GPC() {
|
|||||||
controlIn_SNES();
|
controlIn_SNES();
|
||||||
|
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
createFolder("SNES", "ROM", "GPC4M", "sfc");
|
createFolderAndOpenFile("SNES", "ROM", "GPC4M", "sfc");
|
||||||
|
|
||||||
//clear the screen
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
//open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read Banks
|
// Read Banks
|
||||||
for (int currBank = 0xC0; currBank < 0xC8; currBank++) {
|
for (int currBank = 0xC0; currBank < 0xC8; currBank++) {
|
||||||
|
@ -303,13 +303,7 @@ void readSegment_INTV(uint32_t startaddr, uint32_t endaddr) {
|
|||||||
|
|
||||||
// MODIFIED READ ROUTINE FOR ALL 10 MAPPERS
|
// MODIFIED READ ROUTINE FOR ALL 10 MAPPERS
|
||||||
void readROM_INTV() {
|
void readROM_INTV() {
|
||||||
createFolder("INTV", "ROM", romName, "int");
|
createFolderAndOpenFile("INTV", "ROM", romName, "int");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// open file on sdcard
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
|
|
||||||
switch (intvmapper) {
|
switch (intvmapper) {
|
||||||
case 0: //default mattel up to 32K (8K/12K/16K/24K/32K)
|
case 0: //default mattel up to 32K (8K/12K/16K/24K/32K)
|
||||||
|
@ -522,13 +522,7 @@ void getCartInfo_LOOPY() {
|
|||||||
void readROM_LOOPY() {
|
void readROM_LOOPY() {
|
||||||
dataIn_LOOPY();
|
dataIn_LOOPY();
|
||||||
|
|
||||||
createFolder("LOOPY", "ROM", romName, "bin");
|
createFolderAndOpenFile("LOOPY", "ROM", romName, "bin");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
draw_progressbar(0, cartSize);
|
draw_progressbar(0, cartSize);
|
||||||
|
|
||||||
|
@ -1424,14 +1424,7 @@ void readROM_MD() {
|
|||||||
dataIn_MD();
|
dataIn_MD();
|
||||||
|
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
createFolder("MD", "ROM", romName, "BIN");
|
createFolderAndOpenFile("MD", "ROM", romName, "BIN");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// Open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
byte buffer[1024] = { 0 };
|
byte buffer[1024] = { 0 };
|
||||||
|
|
||||||
@ -2872,14 +2865,7 @@ void readRealtec_MD() {
|
|||||||
dataIn_MD();
|
dataIn_MD();
|
||||||
|
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
createFolder("MD", "ROM", romName, "MD");
|
createFolderAndOpenFile("MD", "ROM", romName, "MD");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// Open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Realtec Registers
|
// Realtec Registers
|
||||||
writeWord_MD(0x201000, 4); // Number of 128K Blocks 0x402000 (0x201000)
|
writeWord_MD(0x201000, 4); // Number of 128K Blocks 0x402000 (0x201000)
|
||||||
|
@ -343,13 +343,7 @@ void readROM_MSX() {
|
|||||||
println_Msg(F("ROM SIZE 0K"));
|
println_Msg(F("ROM SIZE 0K"));
|
||||||
display_Update();
|
display_Update();
|
||||||
} else {
|
} else {
|
||||||
createFolder("MSX", "ROM", romName, "bin");
|
createFolderAndOpenFile("MSX", "ROM", romName, "bin");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// open file on sdcard
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
|
|
||||||
switch (msxmapper) {
|
switch (msxmapper) {
|
||||||
case 0: // No Mapper
|
case 0: // No Mapper
|
||||||
|
@ -4194,13 +4194,7 @@ void resetGameshark_N64() {
|
|||||||
|
|
||||||
// Read rom and save to the SD card
|
// Read rom and save to the SD card
|
||||||
void backupGameshark_N64() {
|
void backupGameshark_N64() {
|
||||||
createFolder("N64", "ROM", "GameShark", "z64");
|
createFolderAndOpenFile("N64", "ROM", "GameShark", "z64");
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// Open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned long currByte = romBase + 0xEC00000; currByte < (romBase + 0xEC00000 + flashSize); currByte += 512) {
|
for (unsigned long currByte = romBase + 0xEC00000; currByte < (romBase + 0xEC00000 + flashSize); currByte += 512) {
|
||||||
// Blink led
|
// Blink led
|
||||||
@ -4563,13 +4557,7 @@ void resetXplorer_N64() {
|
|||||||
// Read rom and save to the SD card
|
// Read rom and save to the SD card
|
||||||
void backupXplorer_N64() {
|
void backupXplorer_N64() {
|
||||||
// create a new folder
|
// create a new folder
|
||||||
createFolder("N64", "ROM", "XPLORER64", "z64");
|
createFolderAndOpenFile("N64", "ROM", "XPLORER64", "z64");
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// Open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned long currByte = 0x10400000; currByte <= 0x1043FFFF; currByte += 512) {
|
for (unsigned long currByte = 0x10400000; currByte <= 0x1043FFFF; currByte += 512) {
|
||||||
// Blink led
|
// Blink led
|
||||||
|
@ -711,14 +711,7 @@ bool selectMapping(FsFile& database) {
|
|||||||
|
|
||||||
void read_NES(const char* fileSuffix, const byte* header, const uint8_t headersize, const boolean renamerom) {
|
void read_NES(const char* fileSuffix, const byte* header, const uint8_t headersize, const boolean renamerom) {
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
createFolder("NES", "ROM", romName, fileSuffix);
|
createFolderAndOpenFile("NES", "ROM", romName, fileSuffix);
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// Open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Initialize progress bar
|
//Initialize progress bar
|
||||||
uint32_t processedProgressBar = 0;
|
uint32_t processedProgressBar = 0;
|
||||||
|
@ -212,14 +212,7 @@ void bankSwitch_ODY2(uint16_t addr, uint8_t data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void readROM_ODY2() {
|
void readROM_ODY2() {
|
||||||
createFolder("ODY2", "ROM", romName, "bin");
|
createFolderAndOpenFile("ODY2", "ROM", romName, "bin");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// open file on sdcard
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ody2mapper == 1) { // A10 CONNECTED
|
if (ody2mapper == 1) { // A10 CONNECTED
|
||||||
// Videopac 31: Musician
|
// Videopac 31: Musician
|
||||||
|
@ -239,13 +239,7 @@ void writeData_POKE(uint32_t addr, uint8_t data) {
|
|||||||
//******************************************
|
//******************************************
|
||||||
|
|
||||||
void readROM_POKE() {
|
void readROM_POKE() {
|
||||||
createFolder("POKE", "ROM", romName, "min");
|
createFolderAndOpenFile("POKE", "ROM", romName, "min");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// open file on sdcard
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
|
|
||||||
// read rom
|
// read rom
|
||||||
uint32_t progress = 0;
|
uint32_t progress = 0;
|
||||||
|
@ -647,37 +647,30 @@ void readSRAM_SMS() {
|
|||||||
} else {
|
} else {
|
||||||
system = "SMS";
|
system = "SMS";
|
||||||
}
|
}
|
||||||
createFolder(system, "SAVE", romName, "sav");
|
createFolderAndOpenFile(system, "SAVE", romName, "sav");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
// Write the whole 32KB
|
||||||
|
// When there is only 8KB of SRAM, the contents should be duplicated
|
||||||
|
word bankSize = 16 * 1024UL;
|
||||||
|
for (byte currBank = 0x0; currBank < 2; currBank++) {
|
||||||
|
writeByte_SMS(0xFFFC, 0x08 | (currBank << 2));
|
||||||
|
|
||||||
// Create file on sd card
|
// Blink led
|
||||||
if (myFile.open(fileName, O_RDWR | O_CREAT)) {
|
blinkLED();
|
||||||
// Write the whole 32KB
|
|
||||||
// When there is only 8KB of SRAM, the contents should be duplicated
|
|
||||||
word bankSize = 16 * 1024UL;
|
|
||||||
for (byte currBank = 0x0; currBank < 2; currBank++) {
|
|
||||||
writeByte_SMS(0xFFFC, 0x08 | (currBank << 2));
|
|
||||||
|
|
||||||
// Blink led
|
// Read 16KB from slot 2 which starts at 0x8000
|
||||||
blinkLED();
|
for (word currBuffer = 0; currBuffer < bankSize; currBuffer += 512) {
|
||||||
|
// Fill SD buffer
|
||||||
// Read 16KB from slot 2 which starts at 0x8000
|
for (int currByte = 0; currByte < 512; currByte++) {
|
||||||
for (word currBuffer = 0; currBuffer < bankSize; currBuffer += 512) {
|
sdBuffer[currByte] = readByte_SMS(0x8000 + currBuffer + currByte);
|
||||||
// Fill SD buffer
|
|
||||||
for (int currByte = 0; currByte < 512; currByte++) {
|
|
||||||
sdBuffer[currByte] = readByte_SMS(0x8000 + currBuffer + currByte);
|
|
||||||
}
|
|
||||||
myFile.write(sdBuffer, 512);
|
|
||||||
}
|
}
|
||||||
|
myFile.write(sdBuffer, 512);
|
||||||
}
|
}
|
||||||
// Close file
|
|
||||||
myFile.close();
|
|
||||||
print_STR(press_button_STR, 1);
|
|
||||||
display_Update();
|
|
||||||
} else {
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
}
|
}
|
||||||
|
// Close file
|
||||||
|
myFile.close();
|
||||||
|
print_STR(press_button_STR, 1);
|
||||||
|
display_Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
//**********************************************
|
//**********************************************
|
||||||
|
@ -1291,14 +1291,7 @@ void readROM_SNES() {
|
|||||||
controlIn_SNES();
|
controlIn_SNES();
|
||||||
|
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
createFolder("SNES", "ROM", romName, "sfc");
|
createFolderAndOpenFile("SNES", "ROM", romName, "sfc");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
//open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Dump Derby Stallion '96 (Japan) and Sound Novel Tsukuru (Japan) - Actual Size is 24Mb
|
//Dump Derby Stallion '96 (Japan) and Sound Novel Tsukuru (Japan) - Actual Size is 24Mb
|
||||||
if ((romType == LO) && (numBanks == 96) && ((strcmp("CC86", checksumStr) == 0) || (strcmp("A77B", checksumStr) == 0))) {
|
if ((romType == LO) && (numBanks == 96) && ((strcmp("CC86", checksumStr) == 0) || (strcmp("A77B", checksumStr) == 0))) {
|
||||||
|
@ -167,14 +167,7 @@ void readSlot(bool cartSlot) {
|
|||||||
// Read ST rom to SD card
|
// Read ST rom to SD card
|
||||||
void readRom_ST(unsigned int bankStart, unsigned int bankEnd) {
|
void readRom_ST(unsigned int bankStart, unsigned int bankEnd) {
|
||||||
// create a new folder to save rom file
|
// create a new folder to save rom file
|
||||||
createFolder("ST", "ROM", "SUFAMI_TURBO", "st");
|
createFolderAndOpenFile("ST", "ROM", "SUFAMI_TURBO", "st");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
//open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read specified banks
|
// Read specified banks
|
||||||
readLoRomBanks(bankStart + 0x80, bankEnd + 0x80, &myFile);
|
readLoRomBanks(bankStart + 0x80, bankEnd + 0x80, &myFile);
|
||||||
|
@ -148,11 +148,7 @@ void suprAcanMenu() {
|
|||||||
static void readROM_Acan() {
|
static void readROM_Acan() {
|
||||||
uint32_t crc32 = 0xffffffff;
|
uint32_t crc32 = 0xffffffff;
|
||||||
|
|
||||||
createFolder("/ACAN", "ROM", "rom", "bin");
|
createFolderAndOpenFile("/ACAN", "ROM", "rom", "bin");
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
|
|
||||||
draw_progressbar(0, cartSize);
|
draw_progressbar(0, cartSize);
|
||||||
|
|
||||||
@ -180,11 +176,7 @@ static void readROM_Acan() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void readSRAM_Acan() {
|
static void readSRAM_Acan() {
|
||||||
createFolder("/ACAN", "SAVE", "save", "bin");
|
createFolderAndOpenFile("/ACAN", "SAVE", "save", "bin");
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
|
|
||||||
dataIn_MD();
|
dataIn_MD();
|
||||||
for (uint32_t i = 0; i < 0x10000; i += 1024) {
|
for (uint32_t i = 0; i < 0x10000; i += 1024) {
|
||||||
@ -265,11 +257,7 @@ static void verifySRAM_Acan() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void readUM6650() {
|
static void readUM6650() {
|
||||||
createFolder("/ACAN", "UM6650", "UM6650", "bin");
|
createFolderAndOpenFile("/ACAN", "UM6650", "UM6650", "bin");
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
|
|
||||||
for (uint16_t i = 0; i < 256; i++) {
|
for (uint16_t i = 0; i < 256; i++) {
|
||||||
dataOut_MD();
|
dataOut_MD();
|
||||||
|
@ -413,15 +413,7 @@ void readROM_SV() {
|
|||||||
controlIn_SNES();
|
controlIn_SNES();
|
||||||
|
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
createFolder("SNES", "ROM", "MEMPACK", "bs");
|
createFolderAndOpenFile("SNES", "ROM", "MEMPACK", "bs");
|
||||||
|
|
||||||
//clear the screen
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
//open file on sd card
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read Banks
|
// Read Banks
|
||||||
for (int currBank = 0x40; currBank < 0x50; currBank++) {
|
for (int currBank = 0x40; currBank < 0x50; currBank++) {
|
||||||
|
@ -410,13 +410,7 @@ void getCartInfo_VB() {
|
|||||||
void readROM_VB() {
|
void readROM_VB() {
|
||||||
dataIn_VB();
|
dataIn_VB();
|
||||||
|
|
||||||
createFolder("VBOY", "ROM", romName, "vb");
|
createFolderAndOpenFile("VBOY", "ROM", romName, "vb");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
word d = 0;
|
word d = 0;
|
||||||
uint32_t progress = 0;
|
uint32_t progress = 0;
|
||||||
|
@ -196,13 +196,7 @@ void readSegment_VECTREX(uint16_t startaddr, uint16_t endaddr) {
|
|||||||
//******************************************
|
//******************************************
|
||||||
|
|
||||||
void readROM_VECTREX() {
|
void readROM_VECTREX() {
|
||||||
createFolder("VECTREX", "ROM", romName, "vec");
|
createFolderAndOpenFile("VECTREX", "ROM", romName, "vec");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// open file on sdcard
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(sd_error_STR);
|
|
||||||
|
|
||||||
PB6_DISABLE; // PB6 LOW - Switch Bank
|
PB6_DISABLE; // PB6 LOW - Switch Bank
|
||||||
|
|
||||||
|
@ -553,12 +553,7 @@ static uint16_t readROM_WS(char *outPathBuf, size_t bufferSize) {
|
|||||||
|
|
||||||
static void readSRAM_WS() {
|
static void readSRAM_WS() {
|
||||||
// generate fullname of rom file
|
// generate fullname of rom file
|
||||||
createFolder("WS", "SAVE", romName, "save");
|
createFolderAndOpenFile("WS", "SAVE", romName, "save");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
|
|
||||||
uint32_t bank_size = (sramSize << 7);
|
uint32_t bank_size = (sramSize << 7);
|
||||||
uint16_t end_bank = (bank_size >> 16); // 64KB per bank
|
uint16_t end_bank = (bank_size >> 16); // 64KB per bank
|
||||||
@ -685,12 +680,7 @@ static void writeSRAM_WS() {
|
|||||||
|
|
||||||
static void readEEPROM_WS() {
|
static void readEEPROM_WS() {
|
||||||
// generate fullname of eep file
|
// generate fullname of eep file
|
||||||
createFolder("WS", "SAVE", romName, "eep");
|
createFolderAndOpenFile("WS", "SAVE", romName, "eep");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
|
|
||||||
uint32_t eepromSize = (sramSize << 7);
|
uint32_t eepromSize = (sramSize << 7);
|
||||||
uint32_t bufSize = (eepromSize < 512 ? eepromSize : 512);
|
uint32_t bufSize = (eepromSize < 512 ? eepromSize : 512);
|
||||||
|
@ -185,13 +185,7 @@ uint8_t readByte_WSV(uint32_t addr) {
|
|||||||
//******************************************
|
//******************************************
|
||||||
|
|
||||||
void readROM_WSV() {
|
void readROM_WSV() {
|
||||||
createFolder("WSV", "ROM", romName, "sv");
|
createFolderAndOpenFile("WSV", "ROM", romName, "sv");
|
||||||
|
|
||||||
printAndIncrementFolder(true);
|
|
||||||
|
|
||||||
// open file on sdcard
|
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT))
|
|
||||||
print_FatalError(create_file_STR);
|
|
||||||
|
|
||||||
// start reading rom
|
// start reading rom
|
||||||
dataIn_WSV();
|
dataIn_WSV();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user