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 |
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 |
|
/* |
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: |
205 |
< |
break; |
206 |
< |
case 15: |
207 |
< |
case 16: |
208 |
< |
if (format != RGBFB_R5G5B5) { |
209 |
< |
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR); |
210 |
< |
return false; |
211 |
< |
} |
212 |
< |
break; |
213 |
< |
case 24: |
214 |
< |
case 32: |
215 |
< |
if (format != RGBFB_A8R8G8B8) { |
216 |
< |
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR); |
217 |
< |
return false; |
218 |
< |
} |
219 |
< |
break; |
220 |
< |
default: |
221 |
< |
ErrorAlert(STR_WRONG_SCREEN_DEPTH_ERR); |
222 |
< |
return false; |
223 |
< |
} |
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 |
|
|
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: |
282 |
< |
break; |
283 |
< |
case 15: |
284 |
< |
case 16: |
285 |
< |
// !!! PIXFMT_RGB15 is correct !!! |
286 |
< |
if (format != PIXFMT_RGB15) { |
287 |
< |
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR); |
288 |
< |
return false; |
289 |
< |
} |
290 |
< |
break; |
291 |
< |
case 24: |
292 |
< |
case 32: |
293 |
< |
if (format != PIXFMT_ARGB32) { |
294 |
< |
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR); |
295 |
< |
return false; |
296 |
< |
} |
297 |
< |
break; |
298 |
< |
default: |
299 |
< |
ErrorAlert(STR_WRONG_SCREEN_DEPTH_ERR); |
300 |
< |
return false; |
301 |
< |
} |
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 |
|
|
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: |
387 |
|
struct DimensionInfo dimInfo; |
388 |
|
DisplayInfoHandle handle = FindDisplayInfo(screen_mode_id); |
389 |
|
|
390 |
< |
if (NULL == handle) |
390 |
> |
if (handle == NULL) |
391 |
|
return false; |
392 |
|
|
393 |
|
if (GetDisplayInfoData(handle, (UBYTE *) &dimInfo, sizeof(dimInfo), DTAG_DIMS, 0) <= 0) |
397 |
|
default_height = 1 + dimInfo.Nominal.MaxY - dimInfo.Nominal.MinY; |
398 |
|
default_depth = dimInfo.MaxDepth; |
399 |
|
|
400 |
< |
for (unsigned d=VDEPTH_1BIT; d<=VDEPTH_32BIT; d++) |
401 |
< |
{ |
402 |
< |
if (INVALID_ID != find_mode_for_depth(default_width, default_height, bits_from_depth(video_depth(d)))) |
403 |
< |
{ |
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 |
< |
} |
438 |
< |
} |
405 |
> |
} |
406 |
|
break; |
407 |
|
} |
408 |
|
|
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) |
462 |
< |
{ |
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 |
< |
} |
432 |
> |
} |
433 |
|
return video_open(VideoModes[0]); |
434 |
|
} |
435 |
|
|
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 (INVALID_ID == ID) |
482 |
< |
{ |
447 |
> |
if (ID == INVALID_ID) { |
448 |
|
ErrorAlert(STR_NO_VIDEO_MODE_ERR); |
449 |
|
return false; |
450 |
< |
} |
450 |
> |
} |
451 |
|
|
452 |
|
VideoMonitor.mode = mode; |
453 |
|
|
610 |
|
{ |
611 |
|
// Close and reopen display |
612 |
|
video_close(); |
613 |
< |
if (!video_open(mode)) |
649 |
< |
{ |
613 |
> |
if (!video_open(mode)) { |
614 |
|
ErrorAlert(STR_OPEN_WINDOW_ERR); |
615 |
|
QuitEmulator(); |
616 |
< |
} |
616 |
> |
} |
617 |
|
} |
618 |
|
|
619 |
|
|
814 |
|
VideoModes.push_back(mode); |
815 |
|
} |
816 |
|
|
817 |
< |
// Add standard list of windowed modes for given color depth |
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)); |
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; |
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 |
+ |
} |