ROM-Reader for Super Nintendo / Super Famicom Game Cartridges

Here's the SPC7110 Read/Write SRAM. First, I made a change to romType in getCartInfo() to classify SDD1 and SPC7110 carts as HiROM. I found it easier to handle the changes to read/write SRAM that way. I should also get around to modify dumpROM() to reflect the romType change but since the existing code works, I'll wait to clean it up later.

void getCartInfo() {
...
  // Check if LoROM or HiROM
  romType = dumpByte(0, 65493, false); // 0xFFD5
  if ((romType == 0x32)||(romType == 0x3A)) // SDD1/SPC7110
    romType = 1;  //HiROM
  else
    romType = romType & 1; // 0xFFD5
...
}

Code was added to readSRAM() to enable the SRAM using register 0x4830. The modifications to readSRAM() are in the Dump HiRom SRAM section:

void readSRAM (char* fileName, char* folder) {
...
  // Dump HiRom SRAM
  else if (romType == 1) {
    // SPC7110 SRAM
    if ((romChips == 245)||(romChips == 249)) {
      // Configure SPC7110 SRAM Register
      setDataOut();
      // Set 0x4830 to 0x80
      setSRAMByte(0, 18480, 128, false);
      setDataIn();

      dumpByte(48, 24576, false); // Preconfigure to fix the corrupt 1st byte
      // Sram size
      long lastByte = (long(sramSize) * 128) + 24576;
      display.println("HiROM SRAM");
      display.print("SRAM Size: ");
      display.println(lastByte);
  	  display.display();
      for (long currByte = 24576; currByte < lastByte; currByte++) { //startAddr = 0x6000
        myFile.write(dumpByte(48, currByte, false)); //startBank = 0x30
      }
      setDataOut();
      // Reset 0x4830 to 0x0
      setSRAMByte(0, 18480, 0, false);
      setDataIn();
    } 	
    else {
      dumpByte(48, 24576, true); // Preconfigure to fix the corrupt 1st byte
      // Sram size
      long lastByte = (long(sramSize) * 128) + 24576;
      display.println("HiROM SRAM");
      display.print("SRAM Size: ");
      display.println(lastByte);
  	  display.display();
      for (long currByte = 24576; currByte < lastByte; currByte++) { //startAddr = 0x6000
        myFile.write(dumpByte(48, currByte, true)); //startBank = 0x30; CS high
      }
    }
  }

I made similar changes to writeSRAM() also in the HiRom section:

void writeSRAM () {
...

// HiRom
      else if (sramSize != 0 && romType == 1) {
        // SPC7110 SRAM
        if ((romChips == 245)||(romChips == 249)) {
          // Configure SPC7110 SRAM Register
          // Set 0x4830 to 0x80
          setSRAMByte(0, 18480, 128, false);
          
          long lastByte = (long(sramSize) * 128) + 24576;
          
          display.print(sramSize / 8);
          display.println("Kb HiROM");
          display.println("Writing SRAM...");
          display.display();
          
          // Write to sram bank
          for (long currByte = 24576; currByte < lastByte; currByte++) { //startAddr = 0x6000
            setSRAMByte(48, currByte, myFile.read(), false); //startBank = 0x30
            // blink led
            if (currByte % 100 != 0)
              rgbLed(busy_color);
            else
              rgbLed(off_color);
            // Print Progess to LCD
            progress = currByte * 100 / lastByte;
            if ((progress - lastprogress) > 9) {
              display.print(".");
              display.display();
              lastprogress = progress;
            }
          }
          // Reset SPC7110 SRAM Register
          setDataOut();
          // Reset 0x4830 to 0x0
          setSRAMByte(0, 18480, 0, false);
          setDataIn();
        }
        else {
          long lastByte = (long(sramSize) * 128) + 24576;

          display.print(sramSize / 8);
          display.println("Kb HiROM");
          display.println("Writing SRAM...");
          display.display();
          
          // Write to sram bank
          for (long currByte = 24576; currByte < lastByte; currByte++) { //startAddr = 0x6000
            setSRAMByte(48, currByte, myFile.read(), true); //startBank = 0x30; CS high
            // blink led
              if (currByte % 100 != 0)
                rgbLed(busy_color);
              else
                rgbLed(off_color);
            // Print Progess to LCD
            progress = currByte * 100 / lastByte;
            if ((progress - lastprogress) > 9) {
              display.print(".");
              display.display();
              lastprogress = progress;
            }
          }
        }
      }
...
}

Coming up next: the FEOEZ RTC reading code. I've only done the read RTC code so far. I'm not sure if the write RTC code is really necessary.