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

Comparing BasiliskII/src/video.cpp (file contents):
Revision 1.12 by gbeauche, 2001-06-28T21:36:46Z vs.
Revision 1.19 by cebix, 2001-07-01T21:09:26Z

# Line 31 | Line 31
31   #include "cpu_emulation.h"
32   #include "main.h"
33   #include "macos_util.h"
34 + #include "slot_rom.h"
35   #include "video.h"
36   #include "video_defs.h"
37  
# Line 39 | Line 40
40  
41  
42   // List of supported video modes
43 < std::vector<video_mode> VideoModes;
43 > vector<video_mode> VideoModes;
44  
45   // Description of the main monitor
46   monitor_desc VideoMonitor;
# Line 51 | Line 52 | struct {
52          bool luminance_mapping;         // Luminance mapping on/off
53          bool interrupts_enabled;        // VBL interrupts on/off
54          uint32 gamma_table;                     // Mac address of gamma table
55 +        int alloc_gamma_table_size;     // Allocated size of gamma table
56          uint16 current_mode;            // Currently selected depth/resolution
57          uint32 current_id;
58          uint16 preferred_mode;          // Preferred depth/resolution
59          uint32 preferred_id;
60 <        uint32 sp;                                      // Mac address of Slot Manager parameter block
60 >        uint32 slot_param;                      // Mac address of Slot Manager parameter block
61   } VidLocal;
62  
63  
# Line 65 | Line 67 | struct {
67  
68   static bool has_resolution(uint32 id)
69   {
70 <        std::vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end();
71 <        while (i != end) {
70 >        vector<video_mode>::const_iterator i, end = VideoModes.end();
71 >        for (i = VideoModes.begin(); i != end; ++i) {
72                  if (i->resolution_id == id)
73                          return true;
72                ++i;
74          }
75          return false;
76   }
# Line 79 | Line 80 | static bool has_resolution(uint32 id)
80   *  Find specified mode (depth/resolution) (or VideoModes.end() if not found)
81   */
82  
83 < static std::vector<video_mode>::const_iterator find_mode(uint16 mode, uint32 id)
83 > static vector<video_mode>::const_iterator find_mode(uint16 mode, uint32 id)
84   {
85 <        std::vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end();
86 <        while (i != end) {
85 >        vector<video_mode>::const_iterator i, end = VideoModes.end();
86 >        for (i = VideoModes.begin(); i != end; ++i) {
87                  if (i->resolution_id == id && DepthToAppleMode(i->depth) == mode)
88                          return i;
88                ++i;
89          }
90          return i;
91   }
# Line 98 | Line 98 | static std::vector<video_mode>::const_it
98   static video_depth max_depth_of_resolution(uint32 id)
99   {
100          video_depth m = VDEPTH_1BIT;
101 <        std::vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end();
102 <        while (i != end) {
101 >        vector<video_mode>::const_iterator i, end = VideoModes.end();
102 >        for (i = VideoModes.begin(); i != end; ++i) {
103                  if (i->depth > m)
104                          m = i->depth;
105                ++i;
105          }
106          return m;
107   }
# Line 114 | Line 113 | static video_depth max_depth_of_resoluti
113  
114   static void get_size_of_resolution(uint32 id, uint32 &x, uint32 &y)
115   {
116 <        std::vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end();
117 <        while (i != end) {
116 >        vector<video_mode>::const_iterator i, end = VideoModes.end();
117 >        for (i = VideoModes.begin(); i != end; ++i) {
118                  if (i->resolution_id == id) {
119                          x = i->x;
120                          y = i->y;
121                          return;
122                  }
123 <                ++i;
123 >        }
124 > }
125 >
126 >
127 > /*
128 > *  Find palette size for given color depth
129 > */
130 >
131 > static int palette_size(video_depth depth)
132 > {
133 >        switch (depth) {
134 >                case VDEPTH_1BIT: return 2;
135 >                case VDEPTH_2BIT: return 4;
136 >                case VDEPTH_4BIT: return 16;
137 >                case VDEPTH_8BIT: return 256;
138 >                case VDEPTH_16BIT: return 32;
139 >                case VDEPTH_32BIT: return 256;
140 >                default: return 0;
141          }
142   }
143  
# Line 132 | Line 148 | static void get_size_of_resolution(uint3
148  
149   static void set_gray_palette(void)
150   {
151 <        if (!IsDirectMode(VidLocal.current_mode)) {
152 <                for (int i=0; i<256; i++) {
153 <                        VidLocal.palette[i * 3 + 0] = 127;
154 <                        VidLocal.palette[i * 3 + 1] = 127;
155 <                        VidLocal.palette[i * 3 + 2] = 127;
151 >        for (int i=0; i<256; i++) {
152 >                VidLocal.palette[i * 3 + 0] = 127;
153 >                VidLocal.palette[i * 3 + 1] = 127;
154 >                VidLocal.palette[i * 3 + 2] = 127;
155 >        }
156 >        video_set_palette(VidLocal.palette, 256);
157 > }
158 >
159 >
160 > /*
161 > *  Load gamma-corrected black-to-white ramp to palette for direct-color mode
162 > */
163 >
164 > static void load_ramp_palette(void)
165 > {
166 >        // Find tables for gamma correction
167 >        uint8 *red_gamma, *green_gamma, *blue_gamma;
168 >        bool have_gamma = false;
169 >        int data_width = 0;
170 >        if (VidLocal.gamma_table) {
171 >                uint32 table = VidLocal.gamma_table;
172 >                red_gamma = Mac2HostAddr(table + gFormulaData + ReadMacInt16(table + gFormulaSize));
173 >                int chan_cnt = ReadMacInt16(table + gChanCnt);
174 >                if (chan_cnt == 1)
175 >                        green_gamma = blue_gamma = red_gamma;
176 >                else {
177 >                        int ofs = ReadMacInt16(table + gDataCnt);
178 >                        green_gamma = red_gamma + ofs;
179 >                        blue_gamma = green_gamma + ofs;
180                  }
181 <                video_set_palette(VidLocal.palette);
181 >                data_width = ReadMacInt16(table + gDataWidth);
182 >                have_gamma = true;
183 >        }
184 >
185 >        int num = (VidLocal.desc->mode.depth == VDEPTH_16BIT ? 32 : 256);
186 >        uint8 *p = VidLocal.palette;
187 >        for (int i=0; i<num; i++) {
188 >                uint8 red = (i * 256 / num), green = red, blue = red;
189 >                if (have_gamma) {
190 >                        red = red_gamma[red >> (8 - data_width)];
191 >                        green = green_gamma[green >> (8 - data_width)];
192 >                        blue = blue_gamma[blue >> (8 - data_width)];
193 >                }
194 >                *p++ = red;
195 >                *p++ = green;
196 >                *p++ = blue;
197 >        }
198 >
199 >        video_set_palette(VidLocal.palette, num);
200 > }
201 >
202 >
203 > /*
204 > *  Allocate gamma table of specified size
205 > */
206 >
207 > static bool allocate_gamma_table(int size)
208 > {
209 >        M68kRegisters r;
210 >
211 >        if (size > VidLocal.alloc_gamma_table_size) {
212 >                if (VidLocal.gamma_table) {
213 >                        r.a[0] = VidLocal.gamma_table;
214 >                        Execute68kTrap(0xa01f, &r);     // DisposePtr()
215 >                        VidLocal.gamma_table = 0;
216 >                        VidLocal.alloc_gamma_table_size = 0;
217 >                }
218 >                r.d[0] = size;
219 >                Execute68kTrap(0xa71e, &r);     // NewPtrSysClear()
220 >                if (r.a[0] == 0)
221 >                        return false;
222 >                VidLocal.gamma_table = r.a[0];
223 >                VidLocal.alloc_gamma_table_size = size;
224 >        }
225 >        return true;
226 > }
227 >
228 >
229 > /*
230 > *  Set gamma table (0 = build linear ramp)
231 > */
232 >
233 > static bool set_gamma_table(uint32 user_table)
234 > {
235 >        if (user_table == 0) { // Build linear ramp, 256 entries
236 >
237 >                // Allocate new table, if necessary
238 >                if (!allocate_gamma_table(SIZEOF_GammaTbl + 256))
239 >                        return memFullErr;
240 >                uint32 table = VidLocal.gamma_table;
241 >
242 >                // Initialize header
243 >                WriteMacInt16(table + gVersion, 0);
244 >                WriteMacInt16(table + gType, 0);
245 >                WriteMacInt16(table + gFormulaSize, 0);
246 >                WriteMacInt16(table + gChanCnt, 1);
247 >                WriteMacInt16(table + gDataCnt, 256);
248 >                WriteMacInt16(table + gDataWidth, 8);
249 >
250 >                // Build ramp
251 >                uint32 p = table + gFormulaData;
252 >                for (int i=0; i<256; i++)
253 >                        WriteMacInt8(p + i, i);
254 >
255 >        } else { // User-supplied gamma table
256 >
257 >                // Validate header
258 >                if (ReadMacInt16(user_table + gVersion))
259 >                        return paramErr;
260 >                if (ReadMacInt16(user_table + gType))
261 >                        return paramErr;
262 >                int chan_cnt = ReadMacInt16(user_table + gChanCnt);
263 >                if (chan_cnt != 1 && chan_cnt != 3)
264 >                        return paramErr;
265 >                int data_width = ReadMacInt16(user_table + gDataWidth);
266 >                if (data_width > 8)
267 >                        return paramErr;
268 >                int data_cnt = ReadMacInt16(user_table + gDataCnt);
269 >                if (data_cnt != (1 << data_width))
270 >                        return paramErr;
271 >
272 >                // Allocate new table, if necessary
273 >                int size = SIZEOF_GammaTbl + ReadMacInt16(user_table + gFormulaSize) + chan_cnt * data_cnt;
274 >                if (!allocate_gamma_table(size))
275 >                        return memFullErr;
276 >                uint32 table = VidLocal.gamma_table;
277 >
278 >                // Copy table
279 >                Mac2Mac_memcpy(table, user_table, size);
280          }
281 +
282 +        if (IsDirectMode(VidLocal.current_mode))
283 +                load_ramp_palette();
284 +
285 +        return true;
286 + }
287 +
288 +
289 + /*
290 + *  Switch video mode
291 + */
292 +
293 + static void switch_mode(const video_mode &mode, uint32 param, uint32 dce)
294 + {
295 +        // Switch mode
296 +        set_gray_palette();
297 +        video_switch_to_mode(mode);
298 +
299 +        // Update VidLocal
300 +        VidLocal.current_mode = DepthToAppleMode(mode.depth);
301 +        VidLocal.current_id = mode.resolution_id;
302 +
303 +        uint32 frame_base = VidLocal.desc->mac_frame_base;
304 +
305 +        M68kRegisters r;
306 +        uint32 sp = VidLocal.slot_param;
307 +        r.a[0] = sp;
308 +
309 +        // Find functional sResource for this display
310 +        WriteMacInt8(sp + spSlot, ReadMacInt8(dce + dCtlSlot));
311 +        WriteMacInt8(sp + spID, ReadMacInt8(dce + dCtlSlotId));
312 +        WriteMacInt8(sp + spExtDev, 0);
313 +        r.d[0] = 0x0016;
314 +        Execute68kTrap(0xa06e, &r);     // SRsrcInfo()
315 +        uint32 rsrc = ReadMacInt32(sp + spPointer);
316 +
317 +        // Patch minorBase (otherwise rebooting won't work)
318 +        WriteMacInt8(sp + spID, 0x0a); // minorBase
319 +        r.d[0] = 0x0006;
320 +        Execute68kTrap(0xa06e, &r); // SFindStruct()
321 +        uint32 minor_base = ReadMacInt32(sp + spPointer) - ROMBaseMac;
322 +        ROMBaseHost[minor_base + 0] = frame_base >> 24;
323 +        ROMBaseHost[minor_base + 1] = frame_base >> 16;
324 +        ROMBaseHost[minor_base + 2] = frame_base >> 8;
325 +        ROMBaseHost[minor_base + 3] = frame_base;
326 +
327 +        // Patch video mode parameter table
328 +        WriteMacInt32(sp + spPointer, rsrc);
329 +        WriteMacInt8(sp + spID, DepthToAppleMode(mode.depth));
330 +        r.d[0] = 0x0006;
331 +        Execute68kTrap(0xa06e, &r); // SFindStruct()
332 +        WriteMacInt8(sp + spID, 0x01);
333 +        r.d[0] = 0x0006;
334 +        Execute68kTrap(0xa06e, &r); // SFindStruct()
335 +        uint32 p = ReadMacInt32(sp + spPointer) - ROMBaseMac;
336 +        ROMBaseHost[p +  8] = mode.bytes_per_row >> 8;
337 +        ROMBaseHost[p +  9] = mode.bytes_per_row;
338 +        ROMBaseHost[p + 14] = mode.y >> 8;
339 +        ROMBaseHost[p + 15] = mode.y;
340 +        ROMBaseHost[p + 16] = mode.x >> 8;
341 +        ROMBaseHost[p + 17] = mode.x;
342 +
343 +        // Recalculate slot ROM checksum
344 +        ChecksumSlotROM();
345 +
346 +        // Update sResource
347 +        WriteMacInt8(sp + spID, ReadMacInt8(dce + dCtlSlotId));
348 +        r.d[0] = 0x002b;
349 +        Execute68kTrap(0xa06e, &r); // SUpdateSRT()
350 +
351 +        // Update frame buffer base in DCE and param block
352 +        WriteMacInt32(dce + dCtlDevBase, frame_base);
353 +        WriteMacInt32(param + csBaseAddr, frame_base);
354   }
355  
356  
# Line 170 | Line 381 | int16 VideoDriverOpen(uint32 pb, uint32
381          Execute68kTrap(0xa71e, &r);     // NewPtrSysClear()
382          if (r.a[0] == 0)
383                  return memFullErr;
384 <        VidLocal.sp = r.a[0];
385 <        D(bug("SPBlock at %08x\n", VidLocal.sp));
384 >        VidLocal.slot_param = r.a[0];
385 >        D(bug("SPBlock at %08x\n", VidLocal.slot_param));
386  
387          // Find and set default gamma table
388 <        VidLocal.gamma_table = 0; //!!
388 >        VidLocal.gamma_table = 0;
389 >        VidLocal.alloc_gamma_table_size = 0;
390 >        set_gamma_table(0);
391  
392          // Init color palette (solid gray)
393          set_gray_palette();
# Line 204 | Line 417 | int16 VideoDriverControl(uint32 pb, uint
417                                  return paramErr;
418  
419                          if (mode != VidLocal.current_mode) {
420 <                                std::vector<video_mode>::const_iterator i = find_mode(mode, VidLocal.current_id);
420 >                                vector<video_mode>::const_iterator i = find_mode(mode, VidLocal.current_id);
421                                  if (i == VideoModes.end())
422                                          return paramErr;
423 <                                set_gray_palette();
211 <                                video_switch_to_mode(*i);
212 <                                VidLocal.current_mode = mode;
213 <                                WriteMacInt32(param + csBaseAddr, VidLocal.desc->mac_frame_base);
214 <                                WriteMacInt32(dce + dCtlDevBase, VidLocal.desc->mac_frame_base);
423 >                                switch_mode(*i, param, dce);
424                          }
425                          D(bug("  base %08x\n", VidLocal.desc->mac_frame_base));
426                          return noErr;
427                  }
428  
429 <                case cscSetEntries: {   // Set palette
430 <                        D(bug(" SetEntries table %08x, count %d, start %d\n", ReadMacInt32(param + csTable), ReadMacInt16(param + csCount), ReadMacInt16(param + csStart)));
431 <                        if (IsDirectMode(VidLocal.current_mode))
429 >                case cscSetEntries:             // Set palette
430 >                case cscDirectSetEntries: {
431 >                        D(bug(" (Direct)SetEntries table %08x, count %d, start %d\n", ReadMacInt32(param + csTable), ReadMacInt16(param + csCount), ReadMacInt16(param + csStart)));
432 >                        bool is_direct = IsDirectMode(VidLocal.current_mode);
433 >                        if (code == cscSetEntries && is_direct)
434 >                                return controlErr;
435 >                        if (code == cscDirectSetEntries && !is_direct)
436                                  return controlErr;
437  
438                          uint32 s_pal = ReadMacInt32(param + csTable);   // Source palette
# Line 229 | Line 442 | int16 VideoDriverControl(uint32 pb, uint
442                          if (s_pal == 0 || count > 255)
443                                  return paramErr;
444  
445 +                        // Find tables for gamma correction
446 +                        uint8 *red_gamma, *green_gamma, *blue_gamma;
447 +                        bool have_gamma = false;
448 +                        int data_width = 0;
449 +                        if (VidLocal.gamma_table) {
450 +                                uint32 table = VidLocal.gamma_table;
451 +                                red_gamma = Mac2HostAddr(table + gFormulaData + ReadMacInt16(table + gFormulaSize));
452 +                                int chan_cnt = ReadMacInt16(table + gChanCnt);
453 +                                if (chan_cnt == 1)
454 +                                        green_gamma = blue_gamma = red_gamma;
455 +                                else {
456 +                                        int ofs = ReadMacInt16(table + gDataCnt);
457 +                                        green_gamma = red_gamma + ofs;
458 +                                        blue_gamma = green_gamma + ofs;
459 +                                }
460 +                                data_width = ReadMacInt16(table + gDataWidth);
461 +                                have_gamma = true;
462 +                        }
463 +
464 +                        // Convert palette
465                          if (start == 0xffff) {  // Indexed
466                                  for (uint32 i=0; i<=count; i++) {
467                                          d_pal = VidLocal.palette + (ReadMacInt16(s_pal) & 0xff) * 3;
468                                          uint8 red = (uint16)ReadMacInt16(s_pal + 2) >> 8;
469                                          uint8 green = (uint16)ReadMacInt16(s_pal + 4) >> 8;
470                                          uint8 blue = (uint16)ReadMacInt16(s_pal + 6) >> 8;
471 <                                        if (VidLocal.luminance_mapping)
471 >                                        if (VidLocal.luminance_mapping && !is_direct)
472                                                  red = green = blue = (red * 0x4ccc + green * 0x970a + blue * 0x1c29) >> 16;
473 <                                        //!! gamma correction
473 >                                        if (have_gamma) {
474 >                                                red = red_gamma[red >> (8 - data_width)];
475 >                                                green = green_gamma[green >> (8 - data_width)];
476 >                                                blue = blue_gamma[blue >> (8 - data_width)];
477 >                                        }
478                                          *d_pal++ = red;
479                                          *d_pal++ = green;
480                                          *d_pal++ = blue;
# Line 251 | Line 488 | int16 VideoDriverControl(uint32 pb, uint
488                                          uint8 red = (uint16)ReadMacInt16(s_pal + 2) >> 8;
489                                          uint8 green = (uint16)ReadMacInt16(s_pal + 4) >> 8;
490                                          uint8 blue = (uint16)ReadMacInt16(s_pal + 6) >> 8;
491 <                                        if (VidLocal.luminance_mapping)
491 >                                        if (VidLocal.luminance_mapping && !is_direct)
492                                                  red = green = blue = (red * 0x4ccc + green * 0x970a + blue * 0x1c29) >> 16;
493 <                                        //!! gamma correction
493 >                                        if (have_gamma) {
494 >                                                red = red_gamma[red >> (8 - data_width)];
495 >                                                green = green_gamma[green >> (8 - data_width)];
496 >                                                blue = blue_gamma[blue >> (8 - data_width)];
497 >                                        }
498                                          *d_pal++ = red;
499                                          *d_pal++ = green;
500                                          *d_pal++ = blue;
501                                          s_pal += 8;
502                                  }
503                          }
504 <                        video_set_palette(VidLocal.palette);
504 >                        video_set_palette(VidLocal.palette, palette_size(VidLocal.desc->mode.depth));
505                          return noErr;
506                  }
507  
508 <                case cscSetGamma:               // Set gamma table
509 <                        D(bug(" SetGamma\n"));
510 <                        //!!
511 <                        return controlErr;
508 >                case cscSetGamma: {             // Set gamma table
509 >                        uint32 user_table = ReadMacInt32(param + csGTable);
510 >                        D(bug(" SetGamma %08x\n", user_table));
511 >                        return set_gamma_table(user_table) ? noErr : memFullErr;
512 >                }
513  
514                  case cscGrayPage: {             // Fill page with dithered gray pattern
515                          D(bug(" GrayPage %d\n", ReadMacInt16(param + csPage)));
# Line 294 | Line 536 | int16 VideoDriverControl(uint32 pb, uint
536                                  p += VidLocal.desc->mode.bytes_per_row;
537                                  pat = ~pat;
538                          }
539 <                        //!! if direct mode, load gamma table to CLUT
539 >
540 >                        if (IsDirectMode(VidLocal.current_mode))
541 >                                load_ramp_palette();
542 >
543                          return noErr;
544                  }
545  
# Line 327 | Line 572 | int16 VideoDriverControl(uint32 pb, uint
572                                  return paramErr;
573  
574                          if (mode != VidLocal.current_mode || id != VidLocal.current_id) {
575 <                                std::vector<video_mode>::const_iterator i = find_mode(mode, id);
575 >                                vector<video_mode>::const_iterator i = find_mode(mode, id);
576                                  if (i == VideoModes.end())
577                                          return paramErr;
578 <                                set_gray_palette();
334 <                                video_switch_to_mode(*i);
335 <                                VidLocal.current_mode = mode;
336 <                                VidLocal.current_id = id;
337 <                                uint32 frame_base = VidLocal.desc->mac_frame_base;
338 <                                WriteMacInt32(param + csBaseAddr, frame_base);
339 <
340 <                                M68kRegisters r;
341 <                                uint32 sp = VidLocal.sp;
342 <                                r.a[0] = sp;
343 <
344 <                                // Find functional sResource for this display
345 <                                WriteMacInt8(sp + spSlot, ReadMacInt8(dce + dCtlSlot));
346 <                                WriteMacInt8(sp + spID, ReadMacInt8(dce + dCtlSlotId));
347 <                                WriteMacInt8(sp + spExtDev, 0);
348 <                                r.d[0] = 0x0016;
349 <                                Execute68kTrap(0xa06e, &r);     // SRsrcInfo()
350 <                                uint32 rsrc = ReadMacInt32(sp + spPointer);
351 <
352 <                                // Patch minorBase
353 <                                WriteMacInt8(sp + spID, 0x0a); // minorBase
354 <                                r.d[0] = 0x0006;
355 <                                Execute68kTrap(0xa06e, &r); // SFindStruct()
356 <                                uint32 minor_base = ReadMacInt32(sp + spPointer) - ROMBaseMac;
357 <                                ROMBaseHost[minor_base + 0] = frame_base >> 24;
358 <                                ROMBaseHost[minor_base + 1] = frame_base >> 16;
359 <                                ROMBaseHost[minor_base + 2] = frame_base >> 8;
360 <                                ROMBaseHost[minor_base + 3] = frame_base;
361 <
362 <                                // Patch video mode parameter table
363 <                                WriteMacInt32(sp + spPointer, rsrc);
364 <                                WriteMacInt8(sp + spID, mode);
365 <                                r.d[0] = 0x0006;
366 <                                Execute68kTrap(0xa06e, &r); // SFindStruct()
367 <                                WriteMacInt8(sp + spID, 0x01);
368 <                                r.d[0] = 0x0006;
369 <                                Execute68kTrap(0xa06e, &r); // SFindStruct()
370 <                                uint32 p = ReadMacInt32(sp + spPointer) - ROMBaseMac;
371 <                                ROMBaseHost[p +  8] = i->bytes_per_row >> 8;
372 <                                ROMBaseHost[p +  9] = i->bytes_per_row;
373 <                                ROMBaseHost[p + 14] = i->y >> 8;
374 <                                ROMBaseHost[p + 15] = i->y;
375 <                                ROMBaseHost[p + 16] = i->x >> 8;
376 <                                ROMBaseHost[p + 17] = i->x;
377 <
378 <                                // Update sResource
379 <                                WriteMacInt8(sp + spID, ReadMacInt8(dce + dCtlSlotId));
380 <                                r.d[0] = 0x002b;
381 <                                Execute68kTrap(0xa06e, &r); // SUpdateSRT()
382 <
383 <                                // Update frame buffer base in DCE
384 <                                WriteMacInt32(dce + dCtlDevBase, frame_base);
578 >                                switch_mode(*i, param, dce);
579                          }
580                          D(bug("  base %08x\n", VidLocal.desc->mac_frame_base));
581                          return noErr;
# Line 483 | Line 677 | int16 VideoDriverStatus(uint32 pb, uint3
677                          return noErr;
678  
679                  case cscGetGamma:
680 <                        D(bug(" GetGamma -> \n"));
681 <                        //!!
682 <                        return statusErr;
680 >                        D(bug(" GetGamma -> %08x\n", VidLocal.gamma_table));
681 >                        WriteMacInt32(param + csGTable, VidLocal.gamma_table);
682 >                        return noErr;
683  
684                  case cscGetDefaultMode:         // Get default color depth
685                          D(bug(" GetDefaultMode -> %04x\n", VidLocal.preferred_mode));
# Line 581 | Line 775 | int16 VideoDriverStatus(uint32 pb, uint3
775                          uint16 mode = ReadMacInt16(param + csDepthMode);
776                          D(bug(" GetVideoParameters %04x/%08x\n", mode, id));
777  
778 <                        std::vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end();
779 <                        while (i != end) {
778 >                        vector<video_mode>::const_iterator i, end = VideoModes.end();
779 >                        for (i = VideoModes.begin(); i != end; ++i) {
780                                  if (DepthToAppleMode(i->depth) == mode && i->resolution_id == id) {
781                                          uint32 vp = ReadMacInt32(param + csVPBlockPtr);
782                                          WriteMacInt32(vp + vpBaseOffset, 0);
# Line 637 | Line 831 | int16 VideoDriverStatus(uint32 pb, uint3
831                                          WriteMacInt32(param + csDeviceType, dev_type);
832                                          return noErr;
833                                  }
640                                ++i;
834                          }
835                          return paramErr; // specified resolution/depth not supported
836                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines