ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/slot_rom.cpp
(Generate patch)

Comparing BasiliskII/src/slot_rom.cpp (file contents):
Revision 1.7 by cebix, 2001-06-28T21:19:59Z vs.
Revision 1.13 by cebix, 2002-01-15T14:58:32Z

# Line 1 | Line 1
1   /*
2   *  slot_rom.cpp - Slot declaration ROM
3   *
4 < *  Basilisk II (C) 1996-2001 Christian Bauer
4 > *  Basilisk II (C) 1997-2002 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 42 | Line 42 | static uint8 srom[4096];
42   // Index in srom
43   static uint32 p;
44  
45 <
46 < // Check whether a mode with the specified depth exists
47 < static bool has_depth(video_depth depth)
48 < {
49 <        vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end();
50 <        while (i != end) {
51 <                if (i->depth == depth)
52 <                        return true;
53 <                ++i;
54 <        }
55 <        return false;
56 < }
45 > // Length of slot ROM
46 > static int slot_rom_size = 0;
47  
48  
49   /*
# Line 115 | Line 105 | static void PString(char *str)
105                  srom[p++] = 0;
106   }
107  
108 < static uint32 VModeParms(uint32 width, uint32 height, uint32 bytes_per_row, video_depth depth)
108 > static uint32 VModeParms(const video_mode &mode, video_depth depth)
109   {
110          uint32 ret = p;
111          Long(50);                                       // Length
112          Long(0);                                        // Base offset
113 <        Word(bytes_per_row);            // Row bytes
113 >        Word(video_bytes_per_row(depth, mode.resolution_id));
114          Word(0);                                        // Bounds
115          Word(0);
116 <        Word(height);
117 <        Word(width);
116 >        Word(mode.y);
117 >        Word(mode.x);
118          Word(0);                                        // Version
119          Word(0);                                        // Pack type
120          Long(0);                                        // Pack size
# Line 312 | Line 302 | bool InstallSlotROM(void)
302          Offs(0x80, defaultGamma);
303          EndOfList();
304  
305 <        vidModeParms1 = VModeParms(VideoMonitor.mode.x, VideoMonitor.mode.y, VideoMonitor.mode.bytes_per_row, VDEPTH_1BIT);
306 <        vidModeParms2 = VModeParms(VideoMonitor.mode.x, VideoMonitor.mode.y, VideoMonitor.mode.bytes_per_row, VDEPTH_2BIT);
307 <        vidModeParms4 = VModeParms(VideoMonitor.mode.x, VideoMonitor.mode.y, VideoMonitor.mode.bytes_per_row, VDEPTH_4BIT);
308 <        vidModeParms8 = VModeParms(VideoMonitor.mode.x, VideoMonitor.mode.y, VideoMonitor.mode.bytes_per_row, VDEPTH_8BIT);
309 <        vidModeParms16 = VModeParms(VideoMonitor.mode.x, VideoMonitor.mode.y, VideoMonitor.mode.bytes_per_row, VDEPTH_16BIT);
310 <        vidModeParms32 = VModeParms(VideoMonitor.mode.x, VideoMonitor.mode.y, VideoMonitor.mode.bytes_per_row, VDEPTH_32BIT);
305 >        vidModeParms1 = VModeParms(VideoMonitor.mode, VDEPTH_1BIT);
306 >        vidModeParms2 = VModeParms(VideoMonitor.mode, VDEPTH_2BIT);
307 >        vidModeParms4 = VModeParms(VideoMonitor.mode, VDEPTH_4BIT);
308 >        vidModeParms8 = VModeParms(VideoMonitor.mode, VDEPTH_8BIT);
309 >        vidModeParms16 = VModeParms(VideoMonitor.mode, VDEPTH_16BIT);
310 >        vidModeParms32 = VModeParms(VideoMonitor.mode, VDEPTH_32BIT);
311  
312          vidMode1 = VModeDesc(vidModeParms1, false);
313          vidMode2 = VModeDesc(vidModeParms2, false);
# Line 335 | Line 325 | bool InstallSlotROM(void)
325          Offs(0x0b, minorLength);                        // Frame buffer length
326          Offs(0x40, gammaDir);                           // Gamma directory
327          Rsrc(0x7d, 6);                                          // Video attributes: Default to color, built-in
328 <        if (has_depth(VDEPTH_1BIT))
329 <                Offs(0x80, vidMode1);                   // Video mode parameters for 1 bit
330 <        if (has_depth(VDEPTH_2BIT))
331 <                Offs(0x81, vidMode2);                   // Video mode parameters for 2 bit
332 <        if (has_depth(VDEPTH_4BIT))
333 <                Offs(0x82, vidMode4);                   // Video mode parameters for 4 bit
334 <        if (has_depth(VDEPTH_8BIT))
335 <                Offs(0x83, vidMode8);                   // Video mode parameters for 8 bit
336 <        if (has_depth(VDEPTH_16BIT))
337 <                Offs(0x84, vidMode16);                  // Video mode parameters for 16 bit
338 <        if (has_depth(VDEPTH_32BIT))
339 <                Offs(0x85, vidMode32);                  // Video mode parameters for 32 bit
328 >        if (video_has_depth(VDEPTH_1BIT))
329 >                Offs(DepthToAppleMode(VDEPTH_1BIT), vidMode1);          // Video mode parameters for 1 bit
330 >        if (video_has_depth(VDEPTH_2BIT))
331 >                Offs(DepthToAppleMode(VDEPTH_2BIT), vidMode2);          // Video mode parameters for 2 bit
332 >        if (video_has_depth(VDEPTH_4BIT))
333 >                Offs(DepthToAppleMode(VDEPTH_4BIT), vidMode4);          // Video mode parameters for 4 bit
334 >        if (video_has_depth(VDEPTH_8BIT))
335 >                Offs(DepthToAppleMode(VDEPTH_8BIT), vidMode8);          // Video mode parameters for 8 bit
336 >        if (video_has_depth(VDEPTH_16BIT))
337 >                Offs(DepthToAppleMode(VDEPTH_16BIT), vidMode16);        // Video mode parameters for 16 bit
338 >        if (video_has_depth(VDEPTH_32BIT))
339 >                Offs(DepthToAppleMode(VDEPTH_32BIT), vidMode32);        // Video mode parameters for 32 bit
340          EndOfList();
341  
342          // CPU sResource
# Line 433 | Line 423 | bool InstallSlotROM(void)
423          // Format/header block
424          Offs(0, sRsrcDir);                                      // sResource directory
425          Long(p + 16);                                           // Length of declaration data
426 <        Long(0);                                                        // CRC (calculated below)
426 >        Long(0);                                                        // CRC (calculated later)
427          Word(0x0101);                                           // Rev. level, format
428          Long(0x5a932bc7);                                       // Test pattern
429          Word(0x000f);                                           // Byte lanes
430  
431 +        // Copy slot ROM to Mac ROM
432 +        slot_rom_size = p;
433 +        memcpy(ROMBaseHost + ROMSize - slot_rom_size, srom, slot_rom_size);
434 +
435 +        // Calculate checksum
436 +        ChecksumSlotROM();
437 +        return true;
438 + }
439 +
440 + /*
441 + *  Calculate slot ROM checksum (in-place)
442 + */
443 +
444 + void ChecksumSlotROM(void)
445 + {
446          // Calculate CRC
447 +        uint8 *p = ROMBaseHost + ROMSize - slot_rom_size;
448 +        p[slot_rom_size - 12] = 0;
449 +        p[slot_rom_size - 11] = 0;
450 +        p[slot_rom_size - 10] = 0;
451 +        p[slot_rom_size - 9] = 0;
452          uint32 crc = 0;
453 <        for (uint32 i=0; i<p; i++) {
453 >        for (int i=0; i<slot_rom_size; i++) {
454                  crc = (crc << 1) | (crc >> 31);
455 <                crc += srom[i];
455 >                crc += p[i];
456          }
457 <        srom[p - 12] = crc >> 24;
458 <        srom[p - 11] = crc >> 16;
459 <        srom[p - 10] = crc >> 8;
460 <        srom[p - 9] = crc;
451 <
452 <        // Copy slot ROM to Mac ROM
453 <        memcpy(ROMBaseHost + ROMSize - p, srom, p);
454 <        return true;
457 >        p[slot_rom_size - 12] = crc >> 24;
458 >        p[slot_rom_size - 11] = crc >> 16;
459 >        p[slot_rom_size - 10] = crc >> 8;
460 >        p[slot_rom_size - 9] = crc;
461   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines