mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-12 16:30:44 +00:00
slot ROM checksum is recalculated after patching during resolution switch
This commit is contained in:
parent
d011594d4e
commit
738fa25344
@ -22,5 +22,6 @@
|
||||
#define SLOT_ROM_H
|
||||
|
||||
extern bool InstallSlotROM(void);
|
||||
extern void ChecksumSlotROM(void);
|
||||
|
||||
#endif
|
||||
|
@ -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<p; i++) {
|
||||
crc = (crc << 1) | (crc >> 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<slot_rom_size; i++) {
|
||||
crc = (crc << 1) | (crc >> 31);
|
||||
crc += p[i];
|
||||
}
|
||||
p[slot_rom_size - 12] = crc >> 24;
|
||||
p[slot_rom_size - 11] = crc >> 16;
|
||||
p[slot_rom_size - 10] = crc >> 8;
|
||||
p[slot_rom_size - 9] = crc;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "cpu_emulation.h"
|
||||
#include "main.h"
|
||||
#include "macos_util.h"
|
||||
#include "slot_rom.h"
|
||||
#include "video.h"
|
||||
#include "video_defs.h"
|
||||
|
||||
@ -349,7 +350,7 @@ int16 VideoDriverControl(uint32 pb, uint32 dce)
|
||||
Execute68kTrap(0xa06e, &r); // SRsrcInfo()
|
||||
uint32 rsrc = ReadMacInt32(sp + spPointer);
|
||||
|
||||
// Patch minorBase
|
||||
// Patch minorBase (otherwise rebooting won't work)
|
||||
WriteMacInt8(sp + spID, 0x0a); // minorBase
|
||||
r.d[0] = 0x0006;
|
||||
Execute68kTrap(0xa06e, &r); // SFindStruct()
|
||||
@ -375,6 +376,9 @@ int16 VideoDriverControl(uint32 pb, uint32 dce)
|
||||
ROMBaseHost[p + 16] = i->x >> 8;
|
||||
ROMBaseHost[p + 17] = i->x;
|
||||
|
||||
// Recalculate slot ROM checksum
|
||||
ChecksumSlotROM();
|
||||
|
||||
// Update sResource
|
||||
WriteMacInt8(sp + spID, ReadMacInt8(dce + dCtlSlotId));
|
||||
r.d[0] = 0x002b;
|
||||
|
Loading…
x
Reference in New Issue
Block a user