From 738fa25344a607e5bb6894fc2293e2d688847fd5 Mon Sep 17 00:00:00 2001 From: cebix <> Date: Fri, 29 Jun 2001 12:51:21 +0000 Subject: [PATCH] slot ROM checksum is recalculated after patching during resolution switch --- BasiliskII/src/include/slot_rom.h | 1 + BasiliskII/src/slot_rom.cpp | 45 ++++++++++++++++++++++--------- BasiliskII/src/video.cpp | 6 ++++- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/BasiliskII/src/include/slot_rom.h b/BasiliskII/src/include/slot_rom.h index ed9c5669..c7f65859 100644 --- a/BasiliskII/src/include/slot_rom.h +++ b/BasiliskII/src/include/slot_rom.h @@ -22,5 +22,6 @@ #define SLOT_ROM_H extern bool InstallSlotROM(void); +extern void ChecksumSlotROM(void); #endif diff --git a/BasiliskII/src/slot_rom.cpp b/BasiliskII/src/slot_rom.cpp index 5419d134..15625a66 100644 --- a/BasiliskII/src/slot_rom.cpp +++ b/BasiliskII/src/slot_rom.cpp @@ -42,6 +42,9 @@ static uint8 srom[4096]; // Index in srom static uint32 p; +// Length of slot ROM +static int slot_rom_size = 0; + // Check whether a mode with the specified depth exists static bool has_depth(video_depth depth) @@ -433,23 +436,39 @@ bool InstallSlotROM(void) // Format/header block Offs(0, sRsrcDir); // sResource directory Long(p + 16); // Length of declaration data - Long(0); // CRC (calculated below) + Long(0); // CRC (calculated later) Word(0x0101); // Rev. level, format Long(0x5a932bc7); // Test pattern Word(0x000f); // Byte lanes - // Calculate CRC - uint32 crc = 0; - for (uint32 i=0; i
> 31);
- crc += srom[i];
- }
- srom[p - 12] = crc >> 24;
- srom[p - 11] = crc >> 16;
- srom[p - 10] = crc >> 8;
- srom[p - 9] = crc;
-
// Copy slot ROM to Mac ROM
- memcpy(ROMBaseHost + ROMSize - p, srom, p);
+ slot_rom_size = p;
+ memcpy(ROMBaseHost + ROMSize - slot_rom_size, srom, slot_rom_size);
+
+ // Calculate checksum
+ ChecksumSlotROM();
return true;
}
+
+/*
+ * Calculate slot ROM checksum (in-place)
+ */
+
+void ChecksumSlotROM(void)
+{
+ // Calculate CRC
+ uint8 *p = ROMBaseHost + ROMSize - slot_rom_size;
+ p[slot_rom_size - 12] = 0;
+ p[slot_rom_size - 11] = 0;
+ p[slot_rom_size - 10] = 0;
+ p[slot_rom_size - 9] = 0;
+ uint32 crc = 0;
+ for (uint32 i=0; i