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

Comparing BasiliskII/src/AmigaOS/video_amiga.cpp (file contents):
Revision 1.15 by cebix, 2001-06-30T12:58:07Z vs.
Revision 1.23 by cebix, 2002-03-10T20:17:14Z

# Line 1 | Line 1
1   /*
2   *  video_amiga.cpp - Video/graphics emulation, AmigaOS specific stuff
3   *
4 < *  Basilisk II (C) 1997-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 62 | Line 62 | static UWORD *null_pointer = NULL;                             //
62   static UWORD *current_pointer = (UWORD *)-1;    // Currently visible mouse pointer data
63   static LONG black_pen = -1, white_pen = -1;
64   static struct Process *periodic_proc = NULL;    // Periodic process
65 + static int window_width, window_height;         // width and height for window display
66 + static ULONG screen_mode_id;                    // mode ID for screen display
67  
68   extern struct Task *MainTask;                                   // Pointer to main task (from main_amiga.cpp)
69  
# Line 88 | Line 90 | static const uint8 keycode2mac[0x80] = {
90  
91  
92   // Prototypes
93 + static bool video_open(const video_mode &mode);
94 + static void video_close();
95   static void periodic_func(void);
96 + static void add_mode(uint32 width, uint32 height, uint32 resolution_id, uint32 bytes_per_row, video_depth depth);
97 + static void add_modes(uint32 width, uint32 height, video_depth depth);
98 + static ULONG find_mode_for_depth(uint32 width, uint32 height, uint32 depth);
99 + static ULONG bits_from_depth(video_depth depth);
100 + static bool is_valid_modeid(int display_type, ULONG mode_id);
101 + static bool check_modeid_p96(ULONG mode_id);
102 + static bool check_modeid_cgfx(ULONG mode_id);
103  
104  
105   /*
106   *  Initialization
107   */
108  
98 // Add resolution to list of supported modes and set VideoMonitor
99 static void set_video_monitor(uint32 width, uint32 height, uint32 bytes_per_row, int depth)
100 {
101        video_mode mode;
102
103        mode.x = width;
104        mode.y = height;
105        mode.resolution_id = 0x80;
106        mode.bytes_per_row = bytes_per_row;
107
108        switch (depth) {
109                case 1:
110                        mode.depth = VDEPTH_1BIT;
111                        break;
112                case 2:
113                        mode.depth = VDEPTH_2BIT;
114                        break;
115                case 4:
116                        mode.depth = VDEPTH_4BIT;
117                        break;
118                case 8:
119                        mode.depth = VDEPTH_8BIT;
120                        break;
121                case 15:
122                case 16:
123                        mode.depth = VDEPTH_16BIT;
124                        break;
125                case 24:
126                case 32:
127                        mode.depth = VDEPTH_32BIT;
128                        break;
129        }
130
131        VideoModes.push_back(mode);
132        VideoMonitor.mode = mode;
133 }
109  
110   // Open window
111   static bool init_window(int width, int height)
# Line 154 | Line 129 | static bool init_window(int width, int h
129                  TAG_END
130          );
131          if (the_win == NULL) {
132 <                ErrorAlert(GetString(STR_OPEN_WINDOW_ERR));
132 >                ErrorAlert(STR_OPEN_WINDOW_ERR);
133                  return false;
134          }
135  
136          // Create bitmap ("height + 2" for safety)
137          the_bitmap = AllocBitMap(width, height + 2, 1, BMF_CLEAR, NULL);
138          if (the_bitmap == NULL) {
139 <                ErrorAlert(GetString(STR_NO_MEM_ERR));
139 >                ErrorAlert(STR_NO_MEM_ERR);
140                  return false;
141          }
142  
143          // Add resolution and set VideoMonitor
169        set_video_monitor(width, height, the_bitmap->BytesPerRow, 1);
144          VideoMonitor.mac_frame_base = (uint32)the_bitmap->Planes[0];
145  
146          // Set FgPen and BgPen
# Line 206 | Line 180 | static bool init_pip(int width, int heig
180                  TAG_END
181          );
182          if (the_win == NULL || error) {
183 <                ErrorAlert(GetString(STR_OPEN_WINDOW_ERR));
183 >                ErrorAlert(STR_OPEN_WINDOW_ERR);
184                  return false;
185          }
186  
# Line 215 | Line 189 | static bool init_pip(int width, int heig
189  
190          // Add resolution and set VideoMonitor
191          VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_bitmap, P96BMA_MEMORY);
192 <        set_video_monitor(width, height, p96GetBitMapAttr(the_bitmap, P96BMA_BYTESPERROW), 16);
192 >
193          return true;
194   }
195  
# Line 226 | Line 200 | static bool init_screen_p96(ULONG mode_i
200          ADBSetRelMouseMode(true);
201  
202          // Check if the mode is one we can handle
203 <        uint32 depth = p96GetModeIDAttr(mode_id, P96IDA_DEPTH);
204 <        uint32 format = p96GetModeIDAttr(mode_id, P96IDA_RGBFORMAT);
205 <
206 <        switch (depth) {
207 <                case 8:
234 <                        break;
235 <                case 15:
236 <                case 16:
237 <                        if (format != RGBFB_R5G5B5) {
238 <                                ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR));
239 <                                return false;
240 <                        }
241 <                        break;
242 <                case 24:
243 <                case 32:
244 <                        if (format != RGBFB_A8R8G8B8) {
245 <                                ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR));
246 <                                return false;
247 <                        }
248 <                        break;
249 <                default:
250 <                        ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR));
251 <                        return false;
252 <        }
203 >        if (!check_modeid_p96(mode_id))
204 >                {
205 >                ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR);
206 >                return false;
207 >                }
208  
209          // Yes, get width and height
210 +        uint32 depth = p96GetModeIDAttr(mode_id, P96IDA_DEPTH);
211          uint32 width = p96GetModeIDAttr(mode_id, P96IDA_WIDTH);
212          uint32 height = p96GetModeIDAttr(mode_id, P96IDA_HEIGHT);
213  
# Line 266 | Line 222 | static bool init_screen_p96(ULONG mode_i
222                  TAG_END
223          );
224          if (the_screen == NULL) {
225 <                ErrorAlert(GetString(STR_OPEN_SCREEN_ERR));
225 >                ErrorAlert(STR_OPEN_SCREEN_ERR);
226                  return false;
227          }
228  
# Line 274 | Line 230 | static bool init_screen_p96(ULONG mode_i
230          the_win = OpenWindowTags(NULL,
231                  WA_Left, 0, WA_Top, 0,
232                  WA_Width, width, WA_Height, height,
233 +                WA_SimpleRefresh, TRUE,
234                  WA_NoCareRefresh, TRUE,
235                  WA_Borderless, TRUE,
236                  WA_Activate, TRUE,
# Line 283 | Line 240 | static bool init_screen_p96(ULONG mode_i
240                  TAG_END
241          );
242          if (the_win == NULL) {
243 <                ErrorAlert(GetString(STR_OPEN_WINDOW_ERR));
243 >                ErrorAlert(STR_OPEN_WINDOW_ERR);
244                  return false;
245          }
246  
247          ScreenToFront(the_screen);
248  
249          // Add resolution and set VideoMonitor
293        set_video_monitor(width, height, p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW), depth);
250          VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_MEMORY);
251 +
252          return true;
253   }
254  
# Line 302 | Line 259 | static bool init_screen_cgfx(ULONG mode_
259          ADBSetRelMouseMode(true);
260  
261          // Check if the mode is one we can handle
262 <        uint32 depth = GetCyberIDAttr(CYBRIDATTR_DEPTH, mode_id);
263 <        uint32 format = GetCyberIDAttr(CYBRIDATTR_PIXFMT, mode_id);
264 <
265 <        switch (depth) {
266 <                case 8:
310 <                        break;
311 <                case 15:
312 <                case 16:
313 <                        // !!! PIXFMT_RGB15 is correct !!!
314 <                        if (format != PIXFMT_RGB15) {
315 <                                ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR));
316 <                                return false;
317 <                        }
318 <                        break;
319 <                case 24:
320 <                case 32:
321 <                        if (format != PIXFMT_ARGB32) {
322 <                                ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR));
323 <                                return false;
324 <                        }
325 <                        break;
326 <                default:
327 <                        ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR));
328 <                        return false;
329 <        }
262 >        if (!check_modeid_cgfx(mode_id))
263 >                {
264 >                ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR);
265 >                return false;
266 >                }
267  
268          // Yes, get width and height
269 +        uint32 depth = GetCyberIDAttr(CYBRIDATTR_DEPTH, mode_id);
270          uint32 width = GetCyberIDAttr(CYBRIDATTR_WIDTH, mode_id);
271          uint32 height = GetCyberIDAttr(CYBRIDATTR_HEIGHT, mode_id);
272  
# Line 341 | Line 279 | static bool init_screen_cgfx(ULONG mode_
279                  TAG_END
280          );
281          if (the_screen == NULL) {
282 <                ErrorAlert(GetString(STR_OPEN_SCREEN_ERR));
282 >                ErrorAlert(STR_OPEN_SCREEN_ERR);
283                  return false;
284          }
285  
# Line 349 | Line 287 | static bool init_screen_cgfx(ULONG mode_
287          the_win = OpenWindowTags(NULL,
288                  WA_Left, 0, WA_Top, 0,
289                  WA_Width, width, WA_Height, height,
290 +                WA_SimpleRefresh, TRUE,
291                  WA_NoCareRefresh, TRUE,
292                  WA_Borderless, TRUE,
293                  WA_Activate, TRUE,
# Line 358 | Line 297 | static bool init_screen_cgfx(ULONG mode_
297                  TAG_END
298          );
299          if (the_win == NULL) {
300 <                ErrorAlert(GetString(STR_OPEN_WINDOW_ERR));
300 >                ErrorAlert(STR_OPEN_WINDOW_ERR);
301                  return false;
302          }
303  
# Line 373 | Line 312 | static bool init_screen_cgfx(ULONG mode_
312                  TAG_END
313          );
314          UnLockBitMap(handle);
315 <        set_video_monitor(width, height, GetCyberMapAttr(the_screen->RastPort.BitMap, CYBRMATTR_XMOD), depth);
315 >
316          VideoMonitor.mac_frame_base = frame_base;
317 +
318          return true;
319   }
320  
321   bool VideoInit(bool classic)
322   {
323 +        int default_width, default_height, default_depth;
324 +
325          // Allocate blank mouse pointer data
326          null_pointer = (UWORD *)AllocMem(12, MEMF_PUBLIC | MEMF_CHIP | MEMF_CLEAR);
327          if (null_pointer == NULL) {
328 <                ErrorAlert(GetString(STR_NO_MEM_ERR));
328 >                ErrorAlert(STR_NO_MEM_ERR);
329                  return false;
330          }
331  
# Line 401 | Line 343 | bool VideoInit(bool classic)
343  
344          // Determine type and mode
345          display_type = DISPLAY_WINDOW;
346 <        int width = 512, height = 384;
347 <        ULONG mode_id = 0;
346 >
347 >        default_width = window_width = 512;
348 >        default_height = window_height = 384;
349 >
350          if (mode_str) {
351 <                if (sscanf(mode_str, "win/%d/%d", &width, &height) == 2)
351 >                if (sscanf(mode_str, "win/%d/%d", &window_width, &window_height) == 2)
352                          display_type = DISPLAY_WINDOW;
353 <                else if (sscanf(mode_str, "pip/%d/%d", &width, &height) == 2 && P96Base)
353 >                else if (sscanf(mode_str, "pip/%d/%d", &window_width, &window_height) == 2 && P96Base)
354                          display_type = DISPLAY_PIP;
355 <                else if (sscanf(mode_str, "scr/%08lx", &mode_id) == 1 && (CyberGfxBase || P96Base)) {
356 <                        if (P96Base && p96GetModeIDAttr(mode_id, P96IDA_ISP96))
355 >                else if (sscanf(mode_str, "scr/%08lx", &screen_mode_id) == 1 && (CyberGfxBase || P96Base)) {
356 >                        if (P96Base && p96GetModeIDAttr(screen_mode_id, P96IDA_ISP96))
357                                  display_type = DISPLAY_SCREEN_P96;
358 <                        else if (CyberGfxBase && IsCyberModeID(mode_id))
358 >                        else if (CyberGfxBase && IsCyberModeID(screen_mode_id))
359                                  display_type = DISPLAY_SCREEN_CGFX;
360                          else {
361 <                                ErrorAlert(GetString(STR_NO_P96_MODE_ERR));
361 >                                ErrorAlert(STR_NO_P96_MODE_ERR);
362                                  return false;
363                          }
364                  }
365          }
366  
367 +        D(bug("display_type %d, window_width %d, window_height %d\n", display_type, window_width, window_height));
368 +
369 +        // Construct list of supported modes
370 +        switch (display_type) {
371 +                case DISPLAY_WINDOW:
372 +                        default_width = window_width;
373 +                        default_height = window_height;
374 +                        default_depth = 1;
375 +                        add_modes(window_width, window_height, VDEPTH_1BIT);
376 +                        break;
377 +
378 +                case DISPLAY_PIP:
379 +                        default_depth = 16;
380 +                        default_width = window_width;
381 +                        default_height = window_height;
382 +                        add_modes(window_width, window_height, VDEPTH_16BIT);
383 +                        break;
384 +
385 +                case DISPLAY_SCREEN_P96:
386 +                case DISPLAY_SCREEN_CGFX:
387 +                        struct DimensionInfo dimInfo;
388 +                        DisplayInfoHandle handle = FindDisplayInfo(screen_mode_id);
389 +
390 +                        if (handle == NULL)
391 +                                return false;
392 +
393 +                        if (GetDisplayInfoData(handle, (UBYTE *) &dimInfo, sizeof(dimInfo), DTAG_DIMS, 0) <= 0)
394 +                                return false;
395 +
396 +                        default_width = 1 + dimInfo.Nominal.MaxX - dimInfo.Nominal.MinX;
397 +                        default_height = 1 + dimInfo.Nominal.MaxY - dimInfo.Nominal.MinY;
398 +                        default_depth = dimInfo.MaxDepth;
399 +
400 +                        for (unsigned d=VDEPTH_8BIT; d<=VDEPTH_32BIT; d++) {
401 +                                ULONG mode_id = find_mode_for_depth(default_width, default_height, bits_from_depth(video_depth(d)));
402 +
403 +                                if (is_valid_modeid(display_type, mode_id))
404 +                                        add_modes(default_width, default_height, video_depth(d));
405 +                        }
406 +                        break;
407 +        }
408 +
409 +        video_init_depth_list();
410 +
411 + #if DEBUG
412 +        bug("Available video modes:\n");
413 +        vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end();
414 +        while (i != end) {
415 +                bug(" %dx%d (ID %02x), %d colors\n", i->x, i->y, i->resolution_id, 1 << bits_from_depth(i->depth));
416 +                ++i;
417 +        }
418 + #endif
419 +
420 +        D(bug("VideoInit: def_width=%ld  def_height=%ld  def_depth=%ld\n", default_width, default_height, default_depth));
421 +
422 +        // Find requested default mode and open display
423 +        if (VideoModes.size() == 1)
424 +                return video_open(VideoModes[0]);
425 +        else {
426 +                // Find mode with specified dimensions
427 +                std::vector<video_mode>::const_iterator i, end = VideoModes.end();
428 +                for (i = VideoModes.begin(); i != end; ++i) {
429 +                        D(bug("VideoInit: w=%ld  h=%ld  d=%ld\n", i->x, i->y, bits_from_depth(i->depth)));
430 +                        if (i->x == default_width && i->y == default_height && bits_from_depth(i->depth) == default_depth)
431 +                                return video_open(*i);
432 +                }
433 +                return video_open(VideoModes[0]);
434 +        }
435 +
436 +        return true;
437 + }
438 +
439 +
440 + static bool video_open(const video_mode &mode)
441 + {
442 +        ULONG depth_bits = bits_from_depth(mode.depth);
443 +        ULONG ID = find_mode_for_depth(mode.x, mode.y, depth_bits);
444 +
445 +        D(bug("video_open: width=%ld  height=%ld  depth=%ld  ID=%08lx\n", mode.x, mode.y, depth_bits, ID));
446 +
447 +        if (ID == INVALID_ID) {
448 +                ErrorAlert(STR_NO_VIDEO_MODE_ERR);
449 +                return false;
450 +        }
451 +
452 +        VideoMonitor.mode = mode;
453 +
454          // Open display
455          switch (display_type) {
456                  case DISPLAY_WINDOW:
457 <                        if (!init_window(width, height))
457 >                        if (!init_window(mode.x, mode.y))
458                                  return false;
459                          break;
460  
461                  case DISPLAY_PIP:
462 <                        if (!init_pip(width, height))
462 >                        if (!init_pip(mode.x, mode.y))
463                                  return false;
464                          break;
465  
466                  case DISPLAY_SCREEN_P96:
467 <                        if (!init_screen_p96(mode_id))
467 >                        if (!init_screen_p96(ID))
468                                  return false;
469                          break;
470  
471                  case DISPLAY_SCREEN_CGFX:
472 <                        if (!init_screen_cgfx(mode_id))
472 >                        if (!init_screen_cgfx(ID))
473                                  return false;
474                          break;
475          }
# Line 451 | Line 482 | bool VideoInit(bool classic)
482                  TAG_END
483          );
484          if (periodic_proc == NULL) {
485 <                ErrorAlert(GetString(STR_NO_MEM_ERR));
485 >                ErrorAlert(STR_NO_MEM_ERR);
486                  return false;
487          }
488 +
489          return true;
490   }
491  
492  
493 < /*
462 < *  Deinitialization
463 < */
464 <
465 < void VideoExit(void)
493 > static void video_close()
494   {
495          // Stop periodic process
496          if (periodic_proc) {
# Line 487 | Line 515 | void VideoExit(void)
515                                  ReleasePen(the_win->WScreen->ViewPort.ColorMap, white_pen);
516  
517                                  CloseWindow(the_win);
518 +                                the_win = NULL;
519                          }
520                          break;
521  
# Line 501 | Line 530 | void VideoExit(void)
530  
531                          // Close window
532                          if (the_win)
533 +                                {
534                                  CloseWindow(the_win);
535 +                                the_win = NULL;
536 +                                }
537  
538                          // Close screen
539                          if (the_screen) {
# Line 514 | Line 546 | void VideoExit(void)
546  
547                          // Close window
548                          if (the_win)
549 +                                {
550                                  CloseWindow(the_win);
551 +                                the_win = NULL;
552 +                                }
553  
554                          // Close screen
555                          if (the_screen) {
# Line 533 | Line 568 | void VideoExit(void)
568  
569  
570   /*
571 + *  Deinitialization
572 + */
573 +
574 + void VideoExit(void)
575 + {
576 +        video_close();
577 + }
578 +
579 +
580 + /*
581   *  Set palette
582   */
583  
584 < void video_set_palette(uint8 *pal)
584 > void video_set_palette(uint8 *pal, int num)
585   {
586          if ((display_type == DISPLAY_SCREEN_P96 || display_type == DISPLAY_SCREEN_CGFX)
587           && !IsDirectMode(VideoMonitor.mode)) {
588  
589                  // Convert palette to 32 bits
590                  ULONG table[2 + 256 * 3];
591 <                table[0] = 256 << 16;
592 <                table[256 * 3 + 1] = 0;
593 <                for (int i=0; i<256; i++) {
591 >                table[0] = num << 16;
592 >                table[num * 3 + 1] = 0;
593 >                for (int i=0; i<num; i++) {
594                          table[i*3+1] = pal[i*3] * 0x01010101;
595                          table[i*3+2] = pal[i*3+1] * 0x01010101;
596                          table[i*3+3] = pal[i*3+2] * 0x01010101;
# Line 563 | Line 608 | void video_set_palette(uint8 *pal)
608  
609   void video_switch_to_mode(const video_mode &mode)
610   {
611 +        // Close and reopen display
612 +        video_close();
613 +        if (!video_open(mode)) {
614 +                ErrorAlert(STR_OPEN_WINDOW_ERR);
615 +                QuitEmulator();
616 +        }
617 + }
618 +
619 +
620 + /*
621 + *  Close down full-screen mode (if bringing up error alerts is unsafe while in full-screen mode)
622 + */
623 +
624 + void VideoQuitFullScreen(void)
625 + {
626   }
627  
628  
# Line 737 | Line 797 | static __saveds void periodic_func(void)
797          Forbid();
798          Signal(MainTask, SIGF_SINGLE);
799   }
800 +
801 +
802 + // Add mode to list of supported modes
803 + static void add_mode(uint32 width, uint32 height, uint32 resolution_id, uint32 bytes_per_row, video_depth depth)
804 + {
805 +        video_mode mode;
806 +        mode.x = width;
807 +        mode.y = height;
808 +        mode.resolution_id = resolution_id;
809 +        mode.bytes_per_row = bytes_per_row;
810 +        mode.depth = depth;
811 +
812 +        D(bug("Added video mode: w=%ld  h=%ld  d=%ld\n", width, height, depth));
813 +
814 +        VideoModes.push_back(mode);
815 + }
816 +
817 + // Add standard list of modes for given color depth
818 + static void add_modes(uint32 width, uint32 height, video_depth depth)
819 + {
820 +        D(bug("add_modes: w=%ld  h=%ld  d=%ld\n", width, height, depth));
821 +
822 +        if (width >= 512 && height >= 384)
823 +                add_mode(512, 384, 0x80, TrivialBytesPerRow(512, depth), depth);
824 +        if (width >= 640 && height >= 480)
825 +                add_mode(640, 480, 0x81, TrivialBytesPerRow(640, depth), depth);
826 +        if (width >= 800 && height >= 600)
827 +                add_mode(800, 600, 0x82, TrivialBytesPerRow(800, depth), depth);
828 +        if (width >= 1024 && height >= 768)
829 +                add_mode(1024, 768, 0x83, TrivialBytesPerRow(1024, depth), depth);
830 +        if (width >= 1152 && height >= 870)
831 +                add_mode(1152, 870, 0x84, TrivialBytesPerRow(1152, depth), depth);
832 +        if (width >= 1280 && height >= 1024)
833 +                add_mode(1280, 1024, 0x85, TrivialBytesPerRow(1280, depth), depth);
834 +        if (width >= 1600 && height >= 1200)
835 +                add_mode(1600, 1200, 0x86, TrivialBytesPerRow(1600, depth), depth);
836 + }
837 +
838 +
839 + static ULONG find_mode_for_depth(uint32 width, uint32 height, uint32 depth)
840 + {
841 +        ULONG ID = BestModeID(BIDTAG_NominalWidth, width,
842 +                BIDTAG_NominalHeight, height,
843 +                BIDTAG_Depth, depth,
844 +                BIDTAG_DIPFMustNotHave, DIPF_IS_ECS | DIPF_IS_HAM | DIPF_IS_AA,
845 +                TAG_END);
846 +
847 +        return ID;
848 + }
849 +
850 +
851 + static ULONG bits_from_depth(video_depth depth)
852 + {
853 +        int bits = 1 << depth;
854 +        if (bits == 16)
855 +                bits = 15;
856 +        else if (bits == 32)
857 +                bits = 24;
858 +
859 +        return bits;
860 + }
861 +
862 +
863 + static bool is_valid_modeid(int display_type, ULONG mode_id)
864 + {
865 +        if (INVALID_ID == mode_id)
866 +                return false;
867 +
868 +        switch (display_type) {
869 +                case DISPLAY_SCREEN_P96:
870 +                        return check_modeid_p96(mode_id);
871 +                        break;
872 +                case DISPLAY_SCREEN_CGFX:
873 +                        return check_modeid_cgfx(mode_id);
874 +                        break;
875 +                default:
876 +                        return false;
877 +                        break;
878 +        }
879 + }
880 +
881 +
882 + static bool check_modeid_p96(ULONG mode_id)
883 + {
884 +        // Check if the mode is one we can handle
885 +        uint32 depth = p96GetModeIDAttr(mode_id, P96IDA_DEPTH);
886 +        uint32 format = p96GetModeIDAttr(mode_id, P96IDA_RGBFORMAT);
887 +
888 +        D(bug("check_modeid_p96: mode_id=%08lx  depth=%ld  format=%ld\n", mode_id, depth, format));
889 +
890 +        if (!p96GetModeIDAttr(screen_mode_id, P96IDA_ISP96))
891 +                return false;
892 +
893 +        switch (depth) {
894 +                case 8:
895 +                        break;
896 +                case 15:
897 +                case 16:
898 +                        if (format != RGBFB_R5G5B5)
899 +                                return false;
900 +                        break;
901 +                case 24:
902 +                case 32:
903 +                        if (format != RGBFB_A8R8G8B8)
904 +                                return false;
905 +                        break;
906 +                default:
907 +                        return false;
908 +        }
909 +
910 +        return true;
911 + }
912 +
913 +
914 + static bool check_modeid_cgfx(ULONG mode_id)
915 + {
916 +        uint32 depth = GetCyberIDAttr(CYBRIDATTR_DEPTH, mode_id);
917 +        uint32 format = GetCyberIDAttr(CYBRIDATTR_PIXFMT, mode_id);
918 +
919 +        D(bug("check_modeid_cgfx: mode_id=%08lx  depth=%ld  format=%ld\n", mode_id, depth, format));
920 +
921 +        if (!IsCyberModeID(mode_id))
922 +                return false;
923 +
924 +        switch (depth) {
925 +                case 8:
926 +                        break;
927 +                case 15:
928 +                case 16:
929 +                        if (format != PIXFMT_RGB15)
930 +                                return false;
931 +                        break;
932 +                case 24:
933 +                case 32:
934 +                        if (format != PIXFMT_ARGB32)
935 +                                return false;
936 +                        break;
937 +                default:
938 +                        return false;
939 +        }
940 +
941 +        return true;
942 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines