--- BasiliskII/src/slot_rom.cpp 2001/06/27 19:03:35 1.5 +++ BasiliskII/src/slot_rom.cpp 2001/06/28 21:36:46 1.8 @@ -43,6 +43,19 @@ static uint8 srom[4096]; static uint32 p; +// Check whether a mode with the specified depth exists +static bool has_depth(video_depth depth) +{ + std::vector::const_iterator i = VideoModes.begin(), end = VideoModes.end(); + while (i != end) { + if (i->depth == depth) + return true; + ++i; + } + return false; +} + + /* * Construct slot declaration ROM and copy it into the Mac ROM (must be called after VideoInit()) */ @@ -105,58 +118,58 @@ static void PString(char *str) static uint32 VModeParms(uint32 width, uint32 height, uint32 bytes_per_row, video_depth depth) { uint32 ret = p; - Long(50); // Length - Long(0); // Base offset - Word(bytes_per_row); // Row bytes - Word(0); // Bounds + Long(50); // Length + Long(0); // Base offset + Word(bytes_per_row); // Row bytes + Word(0); // Bounds Word(0); Word(height); Word(width); - Word(0); // Version - Word(0); // Pack type - Long(0); // Pack size - Long(0x00480000); // HRes - Long(0x00480000); // VRes + Word(0); // Version + Word(0); // Pack type + Long(0); // Pack size + Long(0x00480000); // HRes + Long(0x00480000); // VRes switch (depth) { case VDEPTH_1BIT: - Word(0); // Pixel type (indirect) - Word(1); // Pixel size - Word(1); // CmpCount - Word(1); // CmpSize + Word(0); // Pixel type (indirect) + Word(1); // Pixel size + Word(1); // CmpCount + Word(1); // CmpSize break; case VDEPTH_2BIT: - Word(0); // Pixel type (indirect) - Word(2); // Pixel size - Word(1); // CmpCount - Word(2); // CmpSize + Word(0); // Pixel type (indirect) + Word(2); // Pixel size + Word(1); // CmpCount + Word(2); // CmpSize break; case VDEPTH_4BIT: - Word(0); // Pixel type (indirect) - Word(4); // Pixel size - Word(1); // CmpCount - Word(4); // CmpSize + Word(0); // Pixel type (indirect) + Word(4); // Pixel size + Word(1); // CmpCount + Word(4); // CmpSize break; case VDEPTH_8BIT: - Word(0); // Pixel type (indirect) - Word(8); // Pixel size - Word(1); // CmpCount - Word(8); // CmpSize + Word(0); // Pixel type (indirect) + Word(8); // Pixel size + Word(1); // CmpCount + Word(8); // CmpSize break; case VDEPTH_16BIT: - Word(16); // Pixel type (direct) - Word(16); // Pixel size - Word(3); // CmpCount - Word(5); // CmpSize + Word(16); // Pixel type (direct) + Word(16); // Pixel size + Word(3); // CmpCount + Word(5); // CmpSize break; case VDEPTH_32BIT: - Word(16); // Pixel type (direct) - Word(32); // Pixel size - Word(3); // CmpCount - Word(8); // CmpSize + Word(16); // Pixel type (direct) + Word(32); // Pixel size + Word(3); // CmpCount + Word(8); // CmpSize break; } - Long(0); // Plane size - Long(0); // Reserved + Long(0); // Plane size + Long(0); // Reserved return ret; } @@ -220,13 +233,13 @@ bool InstallSlotROM(void) // Video sResource for default mode videoType = p; // Literals - Word(3); Word(1); Word(1); Word(0x4232); // Display Video Apple 'B2' + Word(3); Word(1); Word(1); Word(0x4232); // Display Video Apple 'B2' videoName = p; String("Display_Video_Apple_Basilisk"); minorBase = p; - Long(VideoMonitor.mac_frame_base); // Frame buffer base + Long(VideoMonitor.mac_frame_base); // Frame buffer base minorLength = p; - Long(VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); // Frame buffer size + Long(0); // Frame buffer size (unspecified) videoDrvr = p; // Video driver Long(0x72); // Length @@ -322,35 +335,18 @@ bool InstallSlotROM(void) Offs(0x0b, minorLength); // Frame buffer length Offs(0x40, gammaDir); // Gamma directory Rsrc(0x7d, 6); // Video attributes: Default to color, built-in -#if 0 - Offs(0x80, vidMode1); // Video mode parameters for 1 bit - Offs(0x81, vidMode2); // Video mode parameters for 2 bit - Offs(0x82, vidMode4); // Video mode parameters for 4 bit - Offs(0x83, vidMode8); // Video mode parameters for 8 bit - Offs(0x84, vidMode16); // Video mode parameters for 16 bit - Offs(0x85, vidMode32); // Video mode parameters for 32 bit -#else - switch (VideoMonitor.mode.depth) { - case VDEPTH_1BIT: - Offs(0x80, vidMode1); // Video mode parameters - break; - case VDEPTH_2BIT: - Offs(0x80, vidMode2); // Video mode parameters - break; - case VDEPTH_4BIT: - Offs(0x80, vidMode4); // Video mode parameters - break; - case VDEPTH_8BIT: - Offs(0x80, vidMode8); // Video mode parameters - break; - case VDEPTH_16BIT: - Offs(0x80, vidMode16); // Video mode parameters - break; - case VDEPTH_32BIT: - Offs(0x80, vidMode32); // Video mode parameters - break; - } -#endif + if (has_depth(VDEPTH_1BIT)) + Offs(0x80, vidMode1); // Video mode parameters for 1 bit + if (has_depth(VDEPTH_2BIT)) + Offs(0x81, vidMode2); // Video mode parameters for 2 bit + if (has_depth(VDEPTH_4BIT)) + Offs(0x82, vidMode4); // Video mode parameters for 4 bit + if (has_depth(VDEPTH_8BIT)) + Offs(0x83, vidMode8); // Video mode parameters for 8 bit + if (has_depth(VDEPTH_16BIT)) + Offs(0x84, vidMode16); // Video mode parameters for 16 bit + if (has_depth(VDEPTH_32BIT)) + Offs(0x85, vidMode32); // Video mode parameters for 32 bit EndOfList(); // CPU sResource