42 |
|
// Index in srom |
43 |
|
static uint32 p; |
44 |
|
|
45 |
+ |
// Length of slot ROM |
46 |
+ |
static int slot_rom_size = 0; |
47 |
+ |
|
48 |
|
|
49 |
|
// Check whether a mode with the specified depth exists |
50 |
|
static bool has_depth(video_depth depth) |
436 |
|
// Format/header block |
437 |
|
Offs(0, sRsrcDir); // sResource directory |
438 |
|
Long(p + 16); // Length of declaration data |
439 |
< |
Long(0); // CRC (calculated below) |
439 |
> |
Long(0); // CRC (calculated later) |
440 |
|
Word(0x0101); // Rev. level, format |
441 |
|
Long(0x5a932bc7); // Test pattern |
442 |
|
Word(0x000f); // Byte lanes |
443 |
|
|
444 |
+ |
// Copy slot ROM to Mac ROM |
445 |
+ |
slot_rom_size = p; |
446 |
+ |
memcpy(ROMBaseHost + ROMSize - slot_rom_size, srom, slot_rom_size); |
447 |
+ |
|
448 |
+ |
// Calculate checksum |
449 |
+ |
ChecksumSlotROM(); |
450 |
+ |
return true; |
451 |
+ |
} |
452 |
+ |
|
453 |
+ |
/* |
454 |
+ |
* Calculate slot ROM checksum (in-place) |
455 |
+ |
*/ |
456 |
+ |
|
457 |
+ |
void ChecksumSlotROM(void) |
458 |
+ |
{ |
459 |
|
// Calculate CRC |
460 |
+ |
uint8 *p = ROMBaseHost + ROMSize - slot_rom_size; |
461 |
+ |
p[slot_rom_size - 12] = 0; |
462 |
+ |
p[slot_rom_size - 11] = 0; |
463 |
+ |
p[slot_rom_size - 10] = 0; |
464 |
+ |
p[slot_rom_size - 9] = 0; |
465 |
|
uint32 crc = 0; |
466 |
< |
for (uint32 i=0; i<p; i++) { |
466 |
> |
for (uint32 i=0; i<slot_rom_size; i++) { |
467 |
|
crc = (crc << 1) | (crc >> 31); |
468 |
< |
crc += srom[i]; |
468 |
> |
crc += p[i]; |
469 |
|
} |
470 |
< |
srom[p - 12] = crc >> 24; |
471 |
< |
srom[p - 11] = crc >> 16; |
472 |
< |
srom[p - 10] = crc >> 8; |
473 |
< |
srom[p - 9] = crc; |
451 |
< |
|
452 |
< |
// Copy slot ROM to Mac ROM |
453 |
< |
memcpy(ROMBaseHost + ROMSize - p, srom, p); |
454 |
< |
return true; |
470 |
> |
p[slot_rom_size - 12] = crc >> 24; |
471 |
> |
p[slot_rom_size - 11] = crc >> 16; |
472 |
> |
p[slot_rom_size - 10] = crc >> 8; |
473 |
> |
p[slot_rom_size - 9] = crc; |
474 |
|
} |