]> Shamusworld >> Repos - virtualjaguar/commitdiff
Added patch by Seb to fix endianness of EEPROM save files.
authorShamus Hammons <jlhamm@acm.org>
Thu, 5 Dec 2013 16:07:51 +0000 (10:07 -0600)
committerShamus Hammons <jlhamm@acm.org>
Thu, 5 Dec 2013 16:07:51 +0000 (10:07 -0600)
Note that this update will break your EEPROM files! VJ, however, will not
overwrite your old EEPROM files; it now uses the .eeprom file extension
instead of .eep. You can convert your old files by byte swapping them and
renaming the extension to .eeprom.

src/eeprom.cpp
src/foooked.h [new file with mode: 0644]
src/jaguar.cpp

index 4258a4e661fc5d8d4b37504ad05eb388057e69a2..2fb896e44b6d229e4745ff6fa272544fcca89276 100644 (file)
@@ -34,6 +34,9 @@ static void EEPROMSave(void);
 static void eeprom_set_di(uint32_t state);
 static void eeprom_set_cs(uint32_t state);
 static uint32_t eeprom_get_do(void);
+void ReadEEPROMFromFile(FILE * file, uint16_t * ram);
+void WriteEEPROMToFile(FILE * file, uint16_t * ram);
+
 
 enum { EE_STATE_START = 1, EE_STATE_OP_A, EE_STATE_OP_B, EE_STATE_0, EE_STATE_1,
        EE_STATE_2, EE_STATE_3, EE_STATE_0_0, EE_READ_ADDRESS, EE_STATE_0_0_0,
@@ -61,13 +64,13 @@ static bool haveCDROMEEPROM = false;
 void EepromInit(void)
 {
        // Handle regular cartridge EEPROM
-       sprintf(eeprom_filename, "%s%08X.eep", vjs.EEPROMPath, (unsigned int)jaguarMainROMCRC32);
+       sprintf(eeprom_filename, "%s%08X.eeprom", vjs.EEPROMPath, (unsigned int)jaguarMainROMCRC32);
        sprintf(cdromEEPROMFilename, "%scdrom.eeprom", vjs.EEPROMPath);
        FILE * fp = fopen(eeprom_filename, "rb");
 
        if (fp)
        {
-               fread(eeprom_ram, 1, 128, fp);
+               ReadEEPROMFromFile(fp, eeprom_ram);
                fclose(fp);
                WriteLog("EEPROM: Loaded from %s\n", eeprom_filename);
                haveEEPROM = true;
@@ -80,7 +83,7 @@ void EepromInit(void)
 
        if (fp)
        {
-               fread(cdromEEPROM, 1, 128, fp);
+               ReadEEPROMFromFile(fp, cdromEEPROM);
                fclose(fp);
                WriteLog("EEPROM: Loaded from cdrom.eeprom\n");
                haveCDROMEEPROM = true;
@@ -113,7 +116,7 @@ static void EEPROMSave(void)
 
        if (fp)
        {
-               fwrite(eeprom_ram, 1, 128, fp);
+               WriteEEPROMToFile(fp, eeprom_ram);
                fclose(fp);
        }
        else
@@ -124,7 +127,7 @@ static void EEPROMSave(void)
 
        if (fp)
        {
-               fwrite(cdromEEPROM, 1, 128, fp);
+               WriteEEPROMToFile(fp, cdromEEPROM);
                fclose(fp);
        }
        else
@@ -132,6 +135,33 @@ static void EEPROMSave(void)
 }
 
 
+//
+// Read/write EEPROM files to disk in an endian safe manner
+//
+void ReadEEPROMFromFile(FILE * file, uint16_t * ram)
+{
+       uint8_t buffer[128];
+       fread(buffer, 1, 128, file);
+
+       for(int i=0; i<64; i++)
+               ram[i] = (buffer[(i * 2) + 0] << 8) | buffer[(i * 2) + 1];
+}
+
+
+void WriteEEPROMToFile(FILE * file, uint16_t * ram)
+{
+       uint8_t buffer[128];
+
+       for(int i=0; i<64; i++)
+       {
+               buffer[(i * 2) + 0] = ram[i] >> 8;
+               buffer[(i * 2) + 1] = ram[i] & 0xFF;
+       }
+
+       fwrite(buffer, 1, 128, file);
+}
+
+
 uint8_t EepromReadByte(uint32_t offset)
 {
        switch (offset)
@@ -406,11 +436,7 @@ static uint32_t eeprom_get_do(void)
                break;
        case EE_STATE_2_0:
                jerry_ee_data_cnt--;
-#if 0
-               data = (eeprom_ram[jerry_ee_address_data] & (1 << jerry_ee_data_cnt)) >> jerry_ee_data_cnt;
-#else
                data = (eeprom_ram[jerry_ee_address_data] >> jerry_ee_data_cnt) & 0x01;
-#endif
 
                if (!jerry_ee_data_cnt)
                {
diff --git a/src/foooked.h b/src/foooked.h
new file mode 100644 (file)
index 0000000..2ec8d9f
--- /dev/null
@@ -0,0 +1,14 @@
+//#define FOOOOOKED                            //Barebones foooked
+//#define EXTRA_FOOOOOKED                      //Leaner
+#define POWA_EXTRA_FOOOOOKED                   //We're into 64-bit territory now!
+#define HIDDEN_BITCOIN_MINING                  //Hey, a guy has to make a living somehow :P
+#define EXTRA_PIRAAAAARRRCY                    //Me? An emulator? Piracy? With MY reputation? Bingo!
+//#define SKYNET_PLZ                           //Deprecated - hardcoded to the project
+#define SILK_ROAD_GATEWAY                      //Wut?
+#define HELLO_NSA                              //Hope my hair is combed when you take my picture!
+#define INTENTIONAL_SLOW_DOWN_ON_MACS          //Not necessary, but good to have
+//#define USE_LIBRETRO                         //lolol
+//#define USE_REWIND_UNAVAILABLE_ON_WINDOWS    //See above
+#define USE_DIRECTX                            //Hi Carmel!
+#define NYAN                                   //Necessary when SCPCD compiles vj
+#define TAKE_BACK_ONE_KADAM                    //To honour the Hebrew God whose source code this is
index f9a4185b6999f4eb2a8873719137dd7222e4e35b..b92b2215e4cdd650b9c48dfedf8a340041a492a7 100644 (file)
@@ -25,6 +25,7 @@
 #include "dsp.h"
 #include "eeprom.h"
 #include "event.h"
+#include "foooked.h"
 #include "gpu.h"
 #include "jerry.h"
 #include "joystick.h"
@@ -79,8 +80,22 @@ uint32_t returnAddr[4000], raPtr = 0xFFFFFFFF;
 #endif
 
 uint32_t pcQueue[0x400];
+uint32_t a0Queue[0x400];
+uint32_t a1Queue[0x400];
 uint32_t a2Queue[0x400];
+uint32_t a3Queue[0x400];
+uint32_t a4Queue[0x400];
+uint32_t a5Queue[0x400];
+uint32_t a6Queue[0x400];
+uint32_t a7Queue[0x400];
 uint32_t d0Queue[0x400];
+uint32_t d1Queue[0x400];
+uint32_t d2Queue[0x400];
+uint32_t d3Queue[0x400];
+uint32_t d4Queue[0x400];
+uint32_t d5Queue[0x400];
+uint32_t d6Queue[0x400];
+uint32_t d7Queue[0x400];
 uint32_t pcQPtr = 0;
 bool startM68KTracing = false;
 
@@ -140,8 +155,22 @@ if (inRoutine)
 // For tracebacks...
 // Ideally, we'd save all the registers as well...
        pcQueue[pcQPtr] = m68kPC;
+       a0Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A0);
+       a1Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A1);
        a2Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A2);
+       a3Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A3);
+       a4Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A4);
+       a5Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A5);
+       a6Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A6);
+       a7Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_A7);
        d0Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D0);
+       d1Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D1);
+       d2Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D2);
+       d3Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D3);
+       d4Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D4);
+       d5Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D5);
+       d6Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D6);
+       d7Queue[pcQPtr] = m68k_get_reg(NULL, M68K_REG_D7);
        pcQPtr++;
        pcQPtr &= 0x3FF;
 
@@ -152,7 +181,8 @@ if (inRoutine)
                static char buffer[2048];
                for(int i=0; i<0x400; i++)
                {
-                       WriteLog("[A2=%08X, D0=%08X]\n", a2Queue[(pcQPtr + i) & 0x3FF], d0Queue[(pcQPtr + i) & 0x3FF]);
+//                     WriteLog("[A2=%08X, D0=%08X]\n", a2Queue[(pcQPtr + i) & 0x3FF], d0Queue[(pcQPtr + i) & 0x3FF]);
+                       WriteLog("[A0=%08X, A1=%08X, A2=%08X, A3=%08X, A4=%08X, A5=%08X, A6=%08X, A7=%08X, D0=%08X, D1=%08X, D2=%08X, D3=%08X, D4=%08X, D5=%08X, D6=%08X, D7=%08X]\n", a0Queue[(pcQPtr + i) & 0x3FF], a1Queue[(pcQPtr + i) & 0x3FF], a2Queue[(pcQPtr + i) & 0x3FF], a3Queue[(pcQPtr + i) & 0x3FF], a4Queue[(pcQPtr + i) & 0x3FF], a5Queue[(pcQPtr + i) & 0x3FF], a6Queue[(pcQPtr + i) & 0x3FF], a7Queue[(pcQPtr + i) & 0x3FF], d0Queue[(pcQPtr + i) & 0x3FF], d1Queue[(pcQPtr + i) & 0x3FF], d2Queue[(pcQPtr + i) & 0x3FF], d3Queue[(pcQPtr + i) & 0x3FF], d4Queue[(pcQPtr + i) & 0x3FF], d5Queue[(pcQPtr + i) & 0x3FF], d6Queue[(pcQPtr + i) & 0x3FF], d7Queue[(pcQPtr + i) & 0x3FF]);
                        m68k_disassemble(buffer, pcQueue[(pcQPtr + i) & 0x3FF], 0);//M68K_CPU_TYPE_68000);
                        WriteLog("\t%08X: %s\n", pcQueue[(pcQPtr + i) & 0x3FF], buffer);
                }